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

📄 xterm.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 4 页
字号:
		   back);	}      UNBLOCK_INPUT ();    }  else    {      XMoveArea (XXwindow,		 XXInternalBorder,		 (cursor_vpos + n) * fontinfo->height+XXInternalBorder,		 XXInternalBorder, cursor_vpos * fontinfo->height+XXInternalBorder,		 screen_width * fontinfo->width,		 (flexlines - (cursor_vpos + n)) * fontinfo->height);      if (WindowMapped)	bitblt = 1;      XFlush ();      UNBLOCK_INPUT ();      SIGNAL_INPUT_WHILE (bitblt);      BLOCK_INPUT ();      XFlush ();      XPixSet (XXwindow, XXInternalBorder,	       (flexlines - n) * fontinfo->height+XXInternalBorder,	       screen_width * fontinfo->width,	       n * fontinfo->height, back);      UNBLOCK_INPUT ();    }  /* if (!InUpdate) CursorToggle (); */}/* Substitutes for standard read routine.  Under X not interested in individual * bytes but rather individual packets. */XTread_socket (sd, bufp, numchars)     register int sd;     register char *bufp;     register int numchars;{  int count;  char *where_mapping;  int nbytes;  int stuffpending;  int temp_width, temp_height;  BLOCK_INPUT_DECLARE ()  /* XKeyPressedEvent event; */  /*  typedef struct reply {XEvent event; struct reply *next} Reply;      Reply *replies = NULL;*/  BLOCK_INPUT ();  count = 0;  if (numchars <= 0)    {	/* To keep from overflowing read buffer */      numchars = 1;      --bufp;    }#ifdef SIGIO  while (bitblt || XPending () != 0)#else#ifndef HAVE_SELECT  if (! (fcntl (fileno (stdin), F_GETFL, 0) & O_NDELAY))    {      extern int read_alarm_should_throw;      if (CursorExists)	xfixscreen ();      read_alarm_should_throw = 1;      XPeekEvent (&XXEvent);      read_alarm_should_throw = 0;    }#endif  while (XPending () != 0)#endif    {      /* while there are more events*/      XNextEvent (&XXEvent);      switch (XXEvent.type)	{/*	case X_Reply:	{	extern char *malloc ();	Reply *reply = (Reply *) malloc (sizeof (Reply));	reply->next = replies;	reply->event = XXEvent;	replies = reply;	break;	}*/	default:	  break;	case ExposeWindow:	  if (((XExposeEvent *)&XXEvent)->window == XXIconWindow)	    {	      PendingIconExposure = 1;	    }	  else	    PendingExposure = 1;/* No reason to repeat */	  /* this if several */	  /* ExposeWindow events */	  /* come in quick succes-*/	  /* ion */	  break;	case ExposeRegion:	  if (PendingExposure)	    {	/* Don't bother with */	      /* region events when */	      /* full window event */	      /* is pending */	      break;	    }	  loadxrepbuffer (&XXEvent, &XXqueue);	  if (XXqueue.rindex == XXqueue.windex)	    {	      PendingExposure = 1;	    }	  if ((XXqueue.rindex > XXqueue.mindex) ||	      (XXqueue.windex > XXqueue.mindex) ||		(XXqueue.rindex < 0) ||		  (XXqueue.windex < 0))	    {	      PendingExposure = 1;	    }	  break;	case ExposeCopy:	/* For ExposeCopy sync */	  /* will block all outgoing */	  /* requests until this is */	  /* decremented */	  if (WindowMapped) bitblt = 0;	  break;	case KeyPressed:	  /* bcopy (XXEvent, event, sizeof (XKeyPressedEvent)); */	  where_mapping = XLookupMapping (&XXEvent, &nbytes);	  /* Nasty fix for arrow keys */	  if (!nbytes && IsCursorKey (XXEvent.detail & 0xff))	    {	      switch (XXEvent.detail & 0xff)		{		case KC_CURSOR_LEFT:		  where_mapping = "\002";		  break;		case KC_CURSOR_RIGHT:		  where_mapping = "\006";		  break;		case KC_CURSOR_UP:		  where_mapping = "\020";		  break;		case KC_CURSOR_DOWN:		  where_mapping = "\016";		  break;		}	      nbytes = 1;	    }	  if (numchars - nbytes > 0)	    {	      bcopy (where_mapping, bufp, nbytes);	      bufp += nbytes;	      count += nbytes;	      numchars -= nbytes;	    }/*	  else	    {	      bcopy (where_mapping, bufp, numchars);	      bufp += numchars;	      count += numchars;	      numchars = 0;	      *(bufp-1) = *(where_mapping + nbytes - 1);	    }*/	  break;	case ButtonPressed:	case ButtonReleased:	  switch (spacecheck (Xxrepbuffer.mindex,			      Xxrepbuffer.rindex,			      Xxrepbuffer.windex, 0))	    {	    case 0:	      loadxrepbuffer (&XXEvent,			      &Xxrepbuffer);	      if (informflag && (numchars > 1))		{		  *bufp++ = (char) 'X' & 037; /* C-x */		  ++count;		  --numchars;		  *bufp++ = (char) 0;  /* C-@ */		  ++count;		  --numchars;		}	      break;	    case -1:	      break;	    case -2:	    default:	      fixxrepbuffer ();	      break;	    }	  break;	}    }/*  while (replies) {    Reply *reply = replies;    XPutBackEvent (&reply->event);    replies = reply->next;    free (reply);    }*/  if (count < 0)    count = 0;#ifdef HAVE_SELECT  if (CursorExists#ifdef O_NDELAY#ifdef F_GETFL      && (! (fcntl (fileno (stdin), F_GETFL, 0) & O_NDELAY))#endif#endif      )    xfixscreen ();#endif  UNBLOCK_INPUT ();  return count;}/* refresh bitmap kitchen sink icon */refreshicon (){  BLOCK_INPUT_DECLARE ()  BLOCK_INPUT ();  if (XXIconWindow)    XBitmapBitsPut (XXIconWindow, 0,  0, sink_width, sink_height,		    sink_bits, BlackPixel, WhitePixel,		    XXIconMask, GXcopy, AllPlanes);  XFlush ();  UNBLOCK_INPUT ();}XBitmapIcon (){  BLOCK_INPUT_DECLARE ()  BLOCK_INPUT ();  if (!IconWindow)    {      XSetIconWindow (XXwindow,XXIconWindow);      XSelectInput (XXIconWindow, ExposeWindow);      IconWindow = !IconWindow;    }  UNBLOCK_INPUT ();}XTextIcon (){  BLOCK_INPUT_DECLARE ()  BLOCK_INPUT ();  if (IconWindow)    {      XClearIconWindow (XXwindow);      XSelectInput (XXIconWindow, NoEvent);      IconWindow = !IconWindow;    }  UNBLOCK_INPUT ();}/* Interpreting incoming keycodes. Should have table modifiable as needed * from elisp. *//* Exit gracefully from gnuemacs, doing an autosave and giving a status. */XExitGracefully (disp, event)     Display *disp;     XErrorEvent *event;{  XCleanUp ();  exit (70);}x_io_error (disp)     Display *disp;{  XCleanUp ();  exit (71);}#if 0/* This kludge overcomes the failure to handle EAGAIN and EINTR   in a certain version of X for 386 running system V.  */x_io_error (disp, a, b, c, nwrite)     Display *disp;{  extern _XSend ();  unsigned int pc = ((unsigned int *)&disp)[-1];  if (pc - (unsigned int)&_XSend - 100 < 100       && (errno == EAGAIN || errno == EINTR))    {      /* We were called by `writedata' erroneously.	 Modify a local variable which `writedata'	 will subtract from the number of bytes to be written.  */      nwrite = 0;      return;    }  abort ();}#endifxfixscreen (){  register int temp_width, temp_height;  BLOCK_INPUT_DECLARE ()  /* register int temp_x, temp_y; */  BLOCK_INPUT ();  dumpqueue ();  /* Check that the connection is in fact open.  This works by doing a nop */  /* (well, almost) write operation.  If there is an XIOerror or a */  /* SIGPIPE, exit gracefully.  This fixes the loop-on-logout bug.*/  /* XIOErrorHandler (XExitGracefully); */  XPixFill (XXwindow, 0, 0, 1, 1, back, ClipModeClipped, GXnoop, AllPlanes);  XFlush ();  /* XIOErrorHandler (0); */  if (PendingIconExposure)    {      refreshicon ();      PendingIconExposure = 0;    }  if (PendingExposure)    {      PendingExposure = 0;      ClearCursor ();      XXqueue.rindex = 0;      XXqueue.windex = 0;      XQueryWindow (XXwindow, &windowinfo); /* Dangerous to do */      /* writes here but */      /* otherwise would */      /* have to alter */      /* gnu emacs display */      /* routines to query */      /* when screen garbaged */      temp_width = (windowinfo.width - 2 * XXInternalBorder) / fontinfo->width;      temp_height = (windowinfo.height- 2*XXInternalBorder) / fontinfo->height;      if (temp_width != screen_width || temp_height != screen_height)	change_screen_size (max (5, temp_height), max (10, temp_width));      XXxoffset= windowinfo.x;      XXyoffset = windowinfo.y;      /*if (temp_x != XXxoffset || temp_y != XXyoffset)	XSetOffset (temp_x, temp_y);*/      dumprectangle (0, 0,		     screen_height * fontinfo->height + 2 * XXInternalBorder,		     screen_width * fontinfo->width + 2 * XXInternalBorder);    }  if (!InUpdate)    if (!CursorExists)      CursorToggle ();  XFlush ();  UNBLOCK_INPUT ();  SIGNAL_INPUT ();}x_term_init (){  char *vardisplay;  char *temp_font;  register char *option;  extern XTinterrupt_signal ();  int reversevideo;  Color cdef;  char *progname;  Fset (intern ("window-system-version"), make_number (10));  vardisplay = (alternate_display ? alternate_display		: (char *) egetenv ("DISPLAY"));  if (!vardisplay || *vardisplay == '\0')    {      fprintf (stderr, "DISPLAY environment variable must be set\n");      exit (-200);    }  XXdisplay = XOpenDisplay (vardisplay);  if (XXdisplay == (Display *) 0)    {      fprintf (stderr, "X server not responding.  Check your DISPLAY environment variable.\n");      exit (-200);    }  x_init_1 (1);  Xxrepbuffer.mindex = XREPBUFSIZE - 1;  Xxrepbuffer.windex = 0;  Xxrepbuffer.rindex = 0;  XXqueue.mindex = XREPBUFSIZE - 1;  XXqueue.windex = 0;  XXqueue.rindex = 0;  WindowMapped = 0;  baud_rate = 9600;  min_padding_speed = 10000;  must_write_spaces = 1;  informflag = 1;  meta_key = 1;  visible_bell = 1;#ifdef SIGIO  interrupt_input = 1;#endif  inverse_video = 1;  bitblt = 0;  PendingExposure = 0;  fix_screen_hook = xfixscreen;  clear_screen_hook = XTclear_screen;  clear_end_of_line_hook = XTclear_end_of_line;  ins_del_lines_hook = XTins_del_lines;  change_line_highlight_hook = XTchange_line_highlight;  insert_chars_hook = XTinsert_chars;  output_chars_hook = XToutput_chars;  delete_chars_hook = XTdelete_chars;  ring_bell_hook = XTfeep;  reset_terminal_modes_hook = XTreset_terminal_modes;  set_terminal_modes_hook = XTset_terminal_modes;  update_begin_hook = XTupdate_begin;  update_end_hook = XTupdate_end;  set_terminal_window_hook = XTset_terminal_window;  read_socket_hook = XTread_socket;  move_cursor_hook = XTmove_cursor;  /* raw_move_cursor_hook = XTraw_move_cursor;  */  reassert_line_highlight_hook = XTreassert_line_highlight;  scroll_region_ok = 1;        /* we'll scroll partial screens */  char_ins_del_ok = 0;         /* just as fast to write the line */  line_ins_del_ok = 1;         /* we'll just blt 'em */  fast_clear_end_of_line = 1;  /* X does this well */  memory_below_screen = 0;	/* we don't remember what scrolls				   off the bottom */  dont_calculate_costs = 1;  /* New options section */  IconWindow = 0;  XXborder = 1;  XXInternalBorder = 1;  screen_width = 80;  screen_height = 66;  reversevideo = 0;  XXxoffset = 0;  XXyoffset = 0;  XXdebug = 0;  XErrorHandler (XExitGracefully);  XIOErrorHandler (x_io_error);  progname = "emacs";  if (option = XGetDefault (progname,"ReverseVideo"))    if (strcmp (option,"on") == 0) reversevideo = 1;  if (option = XGetDefault (progname, "BitmapIcon"))    if (strcmp (option, "on") == 0) IconWindow = 1;  if (option = XGetDefault (progname,"BorderWidth"))    XXborder = atoi (option);  if (option = XGetDefault (progname,"InternalBorder"))    XXInternalBorder = atoi (option);  brdr_color = XGetDefault (progname,"Border");  if (!brdr_color) brdr_color = XGetDefault (progname, "BorderColor");  back_color = XGetDefault (progname,"Background");  fore_color = XGetDefault (progname,"Foreground");  mous_color = XGetDefault (progname,"Mouse");  curs_color = XGetDefault (progname,"Cursor");  temp_font  = XGetDefault (progname,"BodyFont");  if (temp_font == 0) temp_font = X_DEFAULT_FONT;  XXcurrentfont = (char *) xmalloc (strlen (temp_font) + 1);  strcpy (XXcurrentfont, temp_font);  /* If user has specified a special keymap for use with Emacs, use it. */  {    char *temp = XGetDefault (progname, "KeyMap");    if (temp) XUseKeymap (temp);  }  if (DisplayCells () > 2)    {      if (fore_color && XParseColor (fore_color, &cdef) &&	  XGetHardwareColor (&cdef))	fore = cdef.pixel;      else	{	  fore_color = "black";

⌨️ 快捷键说明

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