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

📄 xterm.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 4 页
字号:
	  fore = BlackPixel;	}      if (back_color && XParseColor (back_color, &cdef) &&	  XGetHardwareColor (&cdef))	back = cdef.pixel;      else	{	  back_color = "white";	  back = WhitePixel;	}      if (curs_color && XParseColor (curs_color, &cdef) &&	  XGetHardwareColor (&cdef))	curs = cdef.pixel;      else	{	  curs_color = "black";	  curs = BlackPixel;	}      if (mous_color && XParseColor (mous_color, &cdef) &&	  XGetHardwareColor (&cdef))	mous = cdef.pixel;      else	{	  mous_color = "black";	  mous = BlackPixel;	}      if (brdr_color && XParseColor (brdr_color, &cdef) &&	  XGetHardwareColor (&cdef))	brdr = cdef.pixel;      else	{	  brdr_color = "black";	  brdr = BlackPixel;	}    }  else    {      fore_color  = curs_color = mous_color = brdr_color = "black";      fore = curs = mous = brdr = BlackPixel;      back_color = "white";      back = WhitePixel;    }  /*  if (fore_color && DisplayCells () > 2 &&      XParseColor (fore_color, &cdef) && XGetHardwareColor (&cdef))    fore = cdef.pixel;  else if (fore_color && strcmp (fore_color, "black") == 0)    fore = BlackPixel;  else if (fore_color && strcmp (fore_color, "white") == 0)    fore = WhitePixel;  else    {      fore_color = "black";      fore = BlackPixel;    }  if (back_color && DisplayCells () > 2 &&      XParseColor (back_color, &cdef) && XGetHardwareColor (&cdef))    back = cdef.pixel;  else if (back_color && strcmp (back_color, "white") == 0)    back = WhitePixel;  else if (back_color && strcmp (back_color, "black") == 0)    back = BlackPixel;  else    {      back_color = "white";      back = WhitePixel;    }  if (brdr_color && DisplayCells () > 2 &&      XParseColor (brdr_color, &cdef) && XGetHardwareColor (&cdef))    brdr = cdef.pixel;  else if (brdr_color && (!strcmp (brdr_color, "gray") ||			  !strcmp (brdr_color, "grey") ||			  !strcmp (brdr_color, "Gray") ||			  !strcmp (brdr_color, "Grey")))    brdr = BlackPixel;  else if (brdr_color && strcmp (brdr_color, "white") == 0)    brdr = WhitePixel;  else    {      brdr_color = "black";      brdr = BlackPixel;    }  if (curs_color && DisplayCells () > 2 &&      XParseColor (curs_color, &cdef) && XGetHardwareColor (&cdef))    curs = cdef.pixel;  else if (curs_color && strcmp (curs_color, "black") == 0)    curs = BlackPixel;  else if (curs_color && strcmp (curs_color, "white") == 0)    curs = WhitePixel;  else    {      curs_color = "black";      curs = BlackPixel;    }  if (mous_color && DisplayCells () > 2 &&      XParseColor (mous_color, &cdef) && XGetHardwareColor (&cdef))    mous = cdef.pixel;  else if (mous_color && strcmp (mous_color, "black") == 0)    mous = BlackPixel;  else if (mous_color && strcmp (mous_color, "white") == 0)    mous = WhitePixel;  else    {      mous_color = "black";      mous = BlackPixel;    }    */  XXpid = getpid ();  if (XXcurrentfont == (char *) 0)    {      fprintf (stderr, "Memory allocation failure.\n");      exit (-150);    }  default_window = "=80x24+0+0";/* RMS: XTread_socket does not have an interface suitable   for being a signal handler.  In any case, the SIGIO handler is   set up in init_keyboard and X uses the same one as usual.  *//*  signal (SIGIO, XTread_socket); */  signal (SIGPIPE, XExitGracefully);  XQueryWindow (RootWindow, &rootwindowinfo);  strncpy (iconidentity, ICONTAG, MAXICID);  fontinfo = XOpenFont (XXcurrentfont);  if (fontinfo == (FontInfo *) 0)    {      fprintf (stderr, "No font\n");      exit (-98);    }  pixelwidth = screen_width * fontinfo->width + 2 * XXInternalBorder;  pixelheight = screen_height * fontinfo->height + 2 * XXInternalBorder;  XXwindow = XCreateWindow (RootWindow,			    XXxoffset /* Absolute horizontal offset */,			    XXyoffset /* Absolute Vertical offset */,			    pixelwidth, pixelheight,			    XXborder, BlackPixmap, WhitePixmap);  if (!XXwindow)    {      fprintf (stderr, "Unable to create window.\n");      exit (-97);    }  XXIconWindow = XCreateWindow (RootWindow, 0, 0, sink_width, sink_height,				2, WhitePixmap, (Pixmap) NULL);  if (!XXIconWindow)    {      fprintf (stderr, "Unable to create icon window.\n");      fflush (stderr);      exit (-97);    }  XSelectInput (XXIconWindow, NoEvent);  XXIconMask = XStoreBitmap (sink_mask_width, sink_mask_height, sink_mask_bits);  XSelectInput (XXwindow, NoEvent);  XSetResizeHint (XXwindow, 2 * XXInternalBorder, 2 * XXInternalBorder,		  /* fontinfo->width * 1, fontinfo->height * 1, */		  fontinfo->width, fontinfo->height);#if defined (BSD) || defined (HPUX) || defined (IBMRTAIX)  if (gethostname (&iconidentity[sizeof (ICONTAG) - 1],		   (MAXICID - 1) - sizeof (ICONTAG)))#endif    {      iconidentity[sizeof (ICONTAG) - 2] = '\0';    }  XStoreName (XXwindow, &iconidentity[0]);  EmacsCursor = XCreateCursor (16, 16, MouseCursor, MouseMask,			       0, 0, mous, back, GXcopy);  XDefineCursor (XXwindow, EmacsCursor);  flexlines = screen_height;#if 0/* Do not call XPopUpWindow here!  This is too early.   It is supposed ot be called via the term-setup-hook   and not until after lisp/term/x-win.el has had a chance   to process the user's switches.   I am not sure that there are any circumstances under which   this should be done here  -- RMS.  */  XPopUpWindow ();		/* This looks at Vxterm */#endif /* 0 */  if (reversevideo) XFlipColor ();}x_init_1 (unrequest){#ifdef F_SETOWN  extern int old_fcntl_owner;#endif#ifndef USG  extern void init_sigio (), request_sigio (), unrequest_sigio ();#endif  dup2 (dpyno (), 0);  close (dpyno ());  dpyno () = 0;			/* Looks a little strange?				   check the def of the macro;				   it is a genuine lvalue */#ifndef USG  init_sigio ();  request_sigio ();#endif /* USG */#ifdef F_SETOWN  old_fcntl_owner = fcntl (0, F_GETOWN, 0);#ifdef F_SETOWN_SOCK_NEG  fcntl (0, F_SETOWN, -getpid ());	/* stdin is a socket here */#else  fcntl (0, F_SETOWN, getpid ());#endif /* F_SETOWN_SOCK_NEG */#endif /* F_SETOWN */#ifndef USG  if (unrequest) unrequest_sigio ();#endif}/* Process all queued ExposeRegion events. */staticdumpqueue (){  register int i;  XExposeRegionEvent r;  if ((XXqueue.rindex > XXqueue.mindex) ||      (XXqueue.windex > XXqueue.mindex) ||      (XXqueue.rindex < 0) ||      (XXqueue.windex < 0))    {      PendingExposure = 1;    }  else    while (XXqueue.rindex != XXqueue.windex)      {	if (CursorExists)	  CursorToggle ();	unloadxrepbuffer (&r, &XXqueue);	dumprectangle (r.y - XXInternalBorder, r.x - XXInternalBorder,		       r.height, r.width);      }}XSetFlash (){  ring_bell_hook = XTflash;}XSetFeep (){  ring_bell_hook = XTfeep;}XNewFont (newname)     register char *newname;{  FontInfo *temp;  BLOCK_INPUT_DECLARE ()  BLOCK_INPUT ();  XFlush ();  if (XXdebug)    fprintf (stderr, "Request id is %d\n", XXdisplay->request);  temp = XOpenFont (newname);  if (temp == (FontInfo *) 0)    {      UNBLOCK_INPUT_RESIGNAL ();      return -1;    }  XCloseFont (fontinfo);  fontinfo = temp;  XSetResizeHint (XXwindow, 2*XXInternalBorder, 2*XXInternalBorder,		  /* fontinfo->width * 1, fontinfo->height * 1, */		  fontinfo->width, fontinfo->height);  XSetWindowSize (screen_height, screen_width);  UNBLOCK_INPUT_RESIGNAL ();  return 0;}XFlipColor (){  Pixmap temp;  int tempcolor;  char *tempname;  Cursor temp_curs;  BLOCK_INPUT_DECLARE ()  BLOCK_INPUT ();  CursorToggle ();  temp = XMakeTile (fore);  XChangeBackground (XXwindow, temp);  XFreePixmap (temp);  temp = XMakeTile (back);  if (XXborder)    XChangeBorder (XXwindow, temp);  XFreePixmap (temp);  brdr = back;  brdr_color = back_color;  tempcolor = fore;  fore = back;  back = tempcolor;  tempname = fore_color ;  fore_color = back_color;  back_color = tempname;/*  XPixFill (XXwindow, 0, 0, screen_width * fontinfo->width,	    screen_height * fontinfo->height, back, ClipModeClipped,	    GXcopy, AllPlanes);  dumprectangle (0, 0, screen_height * fontinfo->height + 2 * XXInternalBorder,  screen_width * fontinfo -> width + 2 * XXInternalBorder);*/  XRedrawDisplay ();  if (curs == WhitePixel)    {      curs = BlackPixel;      curs_color = "black";    }  else if (curs == BlackPixel)    {      curs = WhitePixel;      curs_color = "white";    }  if (mous == WhitePixel)    {      mous = BlackPixel;      mous_color = "black";    }  else if (mous == BlackPixel)    {      mous = WhitePixel;      mous_color = "white";    }  temp_curs = XCreateCursor (16, 16, MouseCursor, MouseMask, 0, 0,			     mous, back, GXcopy);  XUndefineCursor (XXwindow);  XDefineCursor (XXwindow, temp_curs);  XFreeCursor (EmacsCursor);  bcopy (&temp_curs, &EmacsCursor, sizeof (Cursor));  CursorToggle ();  XFlush ();  UNBLOCK_INPUT ();}XSetOffset (xoff, yoff)     register int xoff, yoff;{  BLOCK_INPUT_DECLARE ()  BLOCK_INPUT ();  if (xoff < 0)    {      XXxoffset = rootwindowinfo.width + (++xoff) - pixelwidth - 4;    }  else    {      XXxoffset = xoff;    }  if (yoff < 0)    {      XXyoffset	= rootwindowinfo.height + (++yoff) - pixelheight - 4;    }  else    {      XXyoffset = yoff;    }  XMoveWindow (XXwindow, XXxoffset, XXyoffset);  UNBLOCK_INPUT ();  /* XWarpMouse (XXwindow, pixelwidth >> 1, pixelheight >> 1); */}XSetWindowSize (rows, cols)     register int rows, cols;{  /* if (rows < 3) rows = 24;     if (cols < 1) cols = 80; */  pixelwidth = cols * fontinfo->width + 2 * XXInternalBorder;  pixelheight = rows * fontinfo->height + 2 * XXInternalBorder;  XChangeWindow (XXwindow, pixelwidth, pixelheight);  XFlush ();  change_screen_size (rows, cols);  PendingExposure = 0;}XPopUpWindow (){  BLOCK_INPUT_DECLARE ()  if (WindowMapped)    return;  BLOCK_INPUT ();  if (!x_edges_specified)    Fx_rubber_band ();  bitblt = 0;  CursorExists = 0;  VisibleX = 0;  VisibleY = 0;  WindowMapped = 1;  XMapWindow (XXwindow);  dumprectangle (0, 0,		 screen_height * fontinfo->height + 2 * XXInternalBorder,		 screen_width * fontinfo->width + 2 * XXInternalBorder);  XSelectInput (XXwindow, KeyPressed | ExposeWindow | ButtonPressed		| ButtonReleased		| ExposeRegion | ExposeCopy);  /*	XWarpMouse (XXwindow, pixelwidth >> 1, pixelheight >> 1);*/  XTmove_cursor (0, 0);  if (IconWindow)    {      XSetIconWindow (XXwindow,XXIconWindow);      XSelectInput (XXIconWindow, ExposeWindow);    }  else    {      XClearIconWindow (XXwindow);      XSelectInput (XXIconWindow, NoEvent);    }  /*  XRedrawDisplay ();*/  XFlush ();  UNBLOCK_INPUT ();}spacecheck (mindex, rindex, windex, minfreespace)     register int mindex, rindex, windex, minfreespace;{  if ((rindex > mindex) || (windex > mindex))    {      /* fprintf (stderr, "Fatal Mouse Buffer Error.\n");	 fprintf (stderr, "%d = mindex, %d = rindex, %d = windex\n",	 mindex, rindex, windex); */      return -2;    }  if (windex >= rindex)    {      if ((mindex - (windex - rindex)) > minfreespace)	return 0;    }  else    {      if (((rindex - windex) - 1) > minfreespace)	return 0;    }  return -1;}loadxrepbuffer (p_xrep, p_buffer)     register XEvent *p_xrep;     register XREPBUFFER *p_buffer;{  p_buffer->xrep[p_buffer->windex] = *p_xrep;  if (p_buffer->windex == p_buffer->mindex)    p_buffer->windex = 0;  else    p_buffer->windex++;}unloadxrepbuffer (p_xrep, p_buffer)     register XEvent *p_xrep;     register XREPBUFFER *p_buffer;{  if (p_buffer->windex == p_buffer->rindex)    return -1;  *p_xrep = p_buffer->xrep[p_buffer->rindex];  if (p_buffer->rindex == p_buffer->mindex)    p_buffer->rindex = 0;  else    p_buffer->rindex++;  return 0;}fixxrepbuffer (){  Xxrepbuffer.mindex = XREPBUFSIZE - 1;  Xxrepbuffer.windex = 0;  Xxrepbuffer.rindex = 0;}#endif /* HAVE_X_WINDOWS */

⌨️ 快捷键说明

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