⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xterm.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 4 页
字号:
    }  if (CursorExists)    {      CursorToggle ();    }  if (InUpdate)    {      if (end != start - 1)	{	  XText (XXwindow,		 (cursor_hpos * fontinfo->width+XXInternalBorder),		 (cursor_vpos * fontinfo->height+XXInternalBorder),		 start,		 end + 1 - start,		 fontinfo->id,		 (CurHL ? back : fore),		 (CurHL ? fore : back));	  XTmove_cursor (cursor_vpos, cursor_hpos + end - start + 1);	}    }  else    {      if ((VisibleX < 0) || (VisibleX >= screen_width))	{	  UNBLOCK_INPUT ();	  return;	}      if ((VisibleY < 0) || (VisibleY >= screen_height))	{	  UNBLOCK_INPUT ();	  return;	}      if (((end - start) + VisibleX) >= screen_width)	{	  end = start + (screen_width - (VisibleX + 1));	}      if (end >= start)	{	   XText (XXwindow,		 (VisibleX * fontinfo->width+XXInternalBorder),		 (VisibleY * fontinfo->height+XXInternalBorder),		 start,		 ((end - start) + 1),		 fontinfo->id,		 (CurHL ? back : fore),		 (CurHL ? fore : back));	  VisibleX = VisibleX + (end - start) + 1;	}      if (!CursorExists) CursorToggle ();    }  UNBLOCK_INPUT ();}staticXToutput_chars (start, len)     register char *start;     register int len;{#ifdef XDEBUG  fprintf (stderr, "XToutput_chars\n");#endif  writechars (start, start + len - 1);}/* The following routine is for the deaf or for the pervert who prefers * that his terminal flash at him rather than beep at him. */static int flashedback;staticXTflash (){#ifdef ITIMER_REAL  struct itimerval itimer;#ifdef XDEBUG  fprintf (stderr, "XTflash\n");#endif  stop_polling ();  signal (SIGALRM, flashback);  getitimer (ITIMER_REAL, &itimer);  itimer.it_value.tv_usec += 250000;  itimer.it_interval.tv_sec = 0;  itimer.it_interval.tv_usec = 0;  flashedback = 0;  setitimer (ITIMER_REAL, &itimer, 0);  {    BLOCK_INPUT_DECLARE ()    BLOCK_INPUT ();    XPixFill (XXwindow, 0, 0, screen_width*fontinfo->width+2*XXInternalBorder,	      screen_height * fontinfo->height+2*XXInternalBorder, WhitePixel,	      ClipModeClipped, GXinvert, AllPlanes);    XFlush ();    UNBLOCK_INPUT ();  }  while (!flashedback) pause ();#endif /* have ITIMER_REAL */}staticflashback (){#ifdef ITIMER_REAL#ifdef SIGIO  int mask = sigblock (sigmask (SIGIO) | sigmask (SIGALRM));#else  int mask = sigblock (sigmask (SIGALRM));#endif  XPixFill (XXwindow, 0, 0, screen_width * fontinfo->width+2*XXInternalBorder,	    screen_height * fontinfo->height+2*XXInternalBorder, WhitePixel,	    ClipModeClipped, GXinvert, AllPlanes);  XFlush ();  flashedback = 1;  sigsetmask (mask);  start_polling ();#endif /* have ITIMER_REAL */}/* A kludge to get a bell */staticXTfeep (){  BLOCK_INPUT_DECLARE ()  BLOCK_INPUT ();#ifdef XDEBUG  fprintf (stderr, "XTfeep\n");#endif  XFeep (0);  UNBLOCK_INPUT ();}/* Artificially creating a cursor is hard, the actual position on the * screen (either where it is or last was) is tracked with VisibleX,Y. * Gnu Emacs code tends to assume a cursor exists in hardward at cursor_hpos,Y * and that output text will appear there.  During updates, the cursor is * supposed to be blinked out and will only reappear after the update * finishes. */CursorToggle (){  if (!WindowMapped)    {      CursorExists = 0;      return 0;    }  if ((VisibleX < 0) || (VisibleX >= screen_width) ||      (VisibleY < 0) || (VisibleY >= screen_height))    {			/* Current Cursor position trash */      /* Not much can be done */      XFlush ();      CursorExists = 0;      return 0;      /* Currently the return values are not */      /* used, but I could anticipate using */      /* them in the future. */    }  if (current_screen->enable[VisibleY] &&      (VisibleX < current_screen->used[VisibleY]))    {      if (CursorExists)	{	  XText (XXwindow,		 VisibleX * fontinfo->width+XXInternalBorder,		 VisibleY * fontinfo->height+XXInternalBorder,		 &current_screen->contents[VisibleY][VisibleX], 1,		 fontinfo->id,		 fore, back);	}      else	{	  XText (XXwindow,		 VisibleX * fontinfo->width+XXInternalBorder,		 VisibleY * fontinfo->height+XXInternalBorder,		 &current_screen->contents[VisibleY][VisibleX], 1,		 fontinfo->id,		 back, curs);	}    }  else if (CursorExists)    {      XPixSet (XXwindow,	       VisibleX * fontinfo->width+XXInternalBorder,	       VisibleY * fontinfo->height+XXInternalBorder,	       fontinfo->width, fontinfo->height, back);    }  else    {      XPixSet (XXwindow,	       VisibleX * fontinfo->width+XXInternalBorder,	       VisibleY * fontinfo->height+XXInternalBorder,	       fontinfo->width, fontinfo->height, curs);    }  CursorExists = !CursorExists;  /* Cursor has either been blinked in */  /* or out */  if (!InUpdate)    {      XFlush ();    }  return 1;}/* This routine is used by routines which are called to paint regions *//* designated by ExposeRegion events.  If the cursor may be in the exposed *//* region, this routine makes sure it is gone so that dumprectangle can *//* toggle it back into existance if dumprectangle is invoked when not in *//* the midst of a screen update. */staticClearCursor (){  BLOCK_INPUT_DECLARE ()  BLOCK_INPUT ();  if (!WindowMapped)    {      CursorExists = 0;      UNBLOCK_INPUT ();      return;    }  if ((VisibleX < 0) || (VisibleX >= screen_width)      || (VisibleY < 0) || (VisibleY >= screen_height))    {			/* Current Cursor position trash */      /* Not much can be done */      CursorExists = 0;      UNBLOCK_INPUT ();      return;    }  XPixSet (XXwindow,	  VisibleX * fontinfo->width+XXInternalBorder,	  VisibleY * fontinfo->height+XXInternalBorder,	  fontinfo->width, fontinfo->height,	  back);  CursorExists = 0;  UNBLOCK_INPUT ();}staticXTupdate_begin (){  BLOCK_INPUT_DECLARE ()  BLOCK_INPUT ();#ifdef XDEBUG  fprintf (stderr, "XTupdate_begin\n");#endif  InUpdate = 1;  if (CursorExists)    {      CursorToggle ();    }  SavedX = cursor_hpos;		/* The initial"hardware" cursor position is */  /*  saved because that is where gnu emacs */  /*  expects the cursor to be at the end of*/  /* the update */  SavedY = cursor_vpos;  dumpqueue ();  UNBLOCK_INPUT ();}staticXTupdate_end (){  BLOCK_INPUT_DECLARE ()  BLOCK_INPUT ();#ifdef XDEBUG  fprintf (stderr, "XTupdate_end\n");#endif  if (CursorExists)    CursorToggle ();  InUpdate = 0;  dumpqueue ();  XTmove_cursor (SavedY, SavedX);	/* XTmove_cursor invokes cursor toggle */  UNBLOCK_INPUT ();}/* Used for expose region and expose copy events.  Have to get the text * back into the newly blank areas. */dumprectangle (top, left, rows, cols)     register int top, left, rows, cols;{  register int index;  int localX, localY, localHL;  rows += top;  cols += left;  top /= fontinfo->height;  /* Get row and col containing up and */  /* left borders of exposed region -- */  /* round down here*/  left /= fontinfo->width;  rows += (fontinfo->height - 1);  cols += (fontinfo->width - 1);  rows /= fontinfo->height;  /* Get row and col containing bottom and */  /* right borders -- round up here */  rows -= top;  cols /= fontinfo->width;  cols -= left;  if (rows < 0) return;  if (cols < 0) return;  if (top > (screen_height - 1)) return;  if (left > (screen_width - 1)) return;  if ((VisibleX >= left) && (VisibleX < (left + cols)) &&      (VisibleY >= top) && (VisibleY < (top + rows)))    {      ClearCursor ();    }  /* should perhaps be DesiredScreen */  /* but PhysScreen is guaranteed to contain*/  /* date which was good for every line on */  /* screen. For desired screen only for */  /* lines which are changing.  Emacs does */  /* not consider a line within a newly */  /* exposed region necessarily to have */  /* been changed.  Emacs knows nothing */  /* about ExposeRegion events.*/  for (localY = top, index = 0;       (index < rows) && (localY < screen_height);       ++index, ++localY)    {      if ((localY < 0) || (localY >= screen_height)) continue;      if (!current_screen->enable[localY]) continue;      if ((left + 1) > current_screen->used[localY]) continue;      localX = left;      localHL = current_screen->highlight[localY];      dumpchars (current_screen,		 min (cols,		      current_screen->used[localY]			- localX),		 localX, localY, localHL);    }  if (!InUpdate && !CursorExists) CursorToggle ();  /* Routine usually called */  /* when not in update */}/* What sections of the window will be modified from the UpdateDisplay * routine is totally under software control.  Any line with Y coordinate * greater than flexlines will not change during an update.  This is really * used only during dellines and inslines routines (scraplines and stufflines) */staticXTset_terminal_window (n)     register int n;{#ifdef XDEBUG  fprintf (stderr, "XTset_terminal_window\n");#endif  if ((n <= 0) || (n > screen_height))    flexlines = screen_height;  else    flexlines = n;}XTins_del_lines (vpos, n)     int vpos, n;{#ifdef XDEBUG  fprintf (stderr, "XTins_del_lines\n");#endif  XTmove_cursor (vpos, 0);  if (n >= 0) stufflines (n);  else scraplines (-n);}staticXTinsert_chars (start, len)     register char *start;     register int len;{#ifdef XDEBUG  fprintf (stderr, "XTinsert_chars\n");#endif  writechars (start, start + len - 1);}staticXTdelete_chars (n)     register int n;{  char *msg = "***Delete Chars Called Outside of Update!!!***";#ifdef XDEBUG  fprintf (stderr, "XTdelete_chars\n");#endif  writechars (msg, msg + strlen (msg) - 1);}staticstufflines (n)     register int n;{  register int topregion, bottomregion;  register int length, newtop;  BLOCK_INPUT_DECLARE ()  if (cursor_vpos >= flexlines)    return;  if (!WindowMapped)    {      bitblt = 0;      return;    }  BLOCK_INPUT ();  if (CursorExists) CursorToggle ();  dumpqueue ();  UNBLOCK_INPUT ();  topregion = cursor_vpos;  bottomregion = flexlines - (n + 1);  newtop = cursor_vpos + n;  length = (bottomregion - topregion) + 1;  if ((length > 0) && (newtop <= flexlines))    {      BLOCK_INPUT ();      /* Should already have cleared */      /* queue of events associated */      /* with old bitblts */      XMoveArea (XXwindow, XXInternalBorder,		 topregion * fontinfo->height+XXInternalBorder,		 XXInternalBorder, newtop * fontinfo->height+XXInternalBorder,		 screen_width * fontinfo->width,		 length * fontinfo->height);      if (WindowMapped)	bitblt = 1;      XFlush ();      UNBLOCK_INPUT ();      SIGNAL_INPUT_WHILE (bitblt);      XFlush ();    }  newtop = min (newtop, (flexlines - 1));  length = newtop - topregion;  if (length > 0)    {      XPixSet (XXwindow,	       XXInternalBorder,	       topregion * fontinfo->height+XXInternalBorder,	       screen_width * fontinfo->width,	       n * fontinfo->height,	       back);    }  /*  if (!InUpdate) CursorToggle (); */}staticscraplines (n)     register int n;{  BLOCK_INPUT_DECLARE ()  if (!WindowMapped)    {      bitblt = 0;      return;    }  if (cursor_vpos >= flexlines)    return;  BLOCK_INPUT ();  if (CursorExists) CursorToggle ();  dumpqueue ();  if ((cursor_vpos + n) >= flexlines)    {      if (flexlines >= (cursor_vpos + 1))	{	  XPixSet (XXwindow,		   XXInternalBorder, cursor_vpos * fontinfo->height+XXInternalBorder,		   screen_width * fontinfo->width,		   (flexlines - cursor_vpos) * fontinfo->height,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -