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

📄 xterm.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 4 页
字号:
/* X Communication module for terminals which understand the X protocol.   Copyright (C) 1985, 1986, 1987, 1988 Free Software Foundation, Inc.This file is part of GNU Emacs.GNU Emacs is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 1, or (at your option)any later version.GNU Emacs is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Emacs; see the file COPYING.  If not, write tothe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  *//* Written by Yakim Martillo, mods and things by Robert Krawitz  *//* *	$Source: /u2/third_party/gnuemacs.chow/src/RCS/xterm.c,v $ *	$Author: rlk $ *	$Locker:  $ *	$Header: xterm.c,v 1.28 86/08/27 13:30:57 rlk Exp $ */#ifndef lintstatic char *rcsid_TrmXTERM_c = "$Header: xterm.c,v 1.28 86/08/27 13:30:57 rlk Exp $";#endif	lint/* On 4.3 this loses if it comes after xterm.h.  */#include <signal.h>#include "config.h"#ifdef HAVE_X_WINDOWS#include "lisp.h"#undef NULL/* This may include sys/types.h, and that somehow loses   if this is not done before the other system files.  */#include "xterm.h"/* Load sys/types.h if not already loaded.   In some systems loading it twice is suicidal.  */#ifndef makedev#include <sys/types.h>#endif#if !defined(USG) || defined(IBMRTAIX)#include <sys/time.h>#else#include <time.h>#endif /* USG and not IBMRTAIX */#include <sys/ioctl.h>#include <fcntl.h>#include <stdio.h>#include <ctype.h>#include <errno.h>#ifdef BSD#include <strings.h>#endif#include <sys/stat.h>#include "dispextern.h"#include "termhooks.h"#include "termopts.h"#include "termchar.h"#include "sink.h"#include "sinkmask.h"#include <X/Xkeyboard.h>/*#include <X/Xproto.h>	*//* Allow config to specify default font.  */#ifndef X_DEFAULT_FONT#define X_DEFAULT_FONT "vtsingle"#endif#define min(a,b) ((a)<(b) ? (a) : (b))#define max(a,b) ((a)>(b) ? (a) : (b))#define sigunblockx(sig) sigblock (0)#define sigblockx(sig) sigblock (1 << ((sig) - 1))XREPBUFFER Xxrepbuffer;int pixelwidth;int pixelheight;int PendingExposure;int PendingIconExposure;#define MAXICID 80char iconidentity[MAXICID];#define ICONTAG "emacs@"#define METABIT 0x80Window XXIconWindow;Bitmap XXIconMask;char *XXcurrentfont;char *default_window;int informflag;extern int initialized;extern char *alternate_display;int XXdebug;int XXpid;extern int screen_garbaged;int XXxoffset, XXyoffset;int IconWindow;int WindowMapped;int CurHL;static int flexlines;		/* last line affect by dellines or */				/* inslines functions */extern int errno;int VisibleX, VisibleY;	/* genuine location of cursor on screen */				/* if it is there */static int SavedX, SavedY;	/* Where the cursor was before update */				/* started */int bitblt;		/* Used to track bit blt events */int CursorExists;	/* during updates cursor is turned off */static int InUpdate;		/* many of functions here may be invoked */				/* even if no update in progress, when */				/* no update is in progress the action */				/* can be slightly different */short MouseCursor[] = {  0x0000, 0x0008, 0x0018, 0x0038,  0x0078, 0x00f8, 0x01f8, 0x03f8,  0x07f8, 0x00f8, 0x00d8, 0x0188,  0x0180, 0x0300, 0x0300, 0x0000};short MouseMask[] = {  0x000c, 0x001c, 0x003c, 0x007c,  0x00fc, 0x01fc, 0x03fc, 0x07fc,  0x0ffc, 0x0ffc, 0x01fc, 0x03dc,  0x03cc, 0x0780, 0x0780, 0x0300};Display *XXdisplay;FontInfo *fontinfo;Window XXwindow;Cursor EmacsCursor;char *fore_color;	/* Variables to store colors */char *back_color;char *brdr_color;char *curs_color;char *mous_color;int fore;int back;int brdr;int curs;int mous;static WindowInfo windowinfo;WindowInfo rootwindowinfo;static XKeyPressedEvent XXEvent; /* as X messages are read in they are */                                /* stored here */static XREPBUFFER XXqueue;/* Used for storing up ExposeRegion */				/* replies, so that the SIGIO inter- */				/* rupt serving routines do almost */				/* no writes to the X socket *//*int CurHL;			/* Current Highlighting actually being */				/* being used for bold font right now*/int XXborder;int XXInternalBorder;int (*handler)();extern Display *XOpenDisplay ();extern Window XCreateWindow ();extern Cursor XDefineCursor ();extern Cursor XCreateCursor ();extern FontInfo *XOpenFont ();static int flashback ();/* HLmode -- Changes the GX function for output strings.  Could be used to * change font.  Check an XText library function call.  */staticHLmode (new)     int new;{  CurHL =  new;}/* External interface to control of standout mode.   Call this when about to modify line at position VPOS   and not change whether it is highlighted.  */XTreassert_line_highlight (highlight, vpos)     int highlight, vpos;{  HLmode (highlight);}/* Call this when about to modify line at position VPOS   and change whether it is highlighted.  */staticXTchange_line_highlight (new_highlight, vpos, first_unused_hpos)     int new_highlight, vpos, first_unused_hpos;{  HLmode (new_highlight);  XTmove_cursor (vpos, 0);  x_clear_end_of_line (0);}/* Used for starting or restarting (after suspension) the X window.  Puts the * cursor in a known place, update does not begin with this routine but only * with a call to redisplay.  The mouse cursor is warped into the window and * then the cursor is turned on. */staticXTset_terminal_modes (){  int stuffpending;#ifdef XDEBUG  fprintf (stderr, "XTset_terminal_modes\n");#endif  InUpdate = 0;  stuffpending = 0;  if (!initialized)    {      CursorExists = 0;      VisibleX = 0;      VisibleY = 0;    }  XTclear_screen ();#ifdef FIONREAD  ioctl (0, FIONREAD, &stuffpending);  if (stuffpending)    SIGNAL_INPUT ();#endif}/* XTmove_cursor moves the cursor to the correct location and checks whether an update * is in progress in order to toggle it on. */staticXTmove_cursor (row, col)     register int row, col;{  BLOCK_INPUT_DECLARE ()  BLOCK_INPUT ();#ifdef XDEBUG  fprintf (stderr, "XTmove_cursor\n");#endif  cursor_hpos = col;  cursor_vpos = row;  if (InUpdate)    {      if (CursorExists)	{	  CursorToggle ();	}      UNBLOCK_INPUT ();      return;		/* Generally, XTmove_cursor will be invoked */      /* when InUpdate with !CursorExists */      /* so that wasteful XFlush is not called */    }  if ((row == VisibleY) && (col == VisibleX))    {      if (!CursorExists)	{	  CursorToggle ();	}      XFlush ();      UNBLOCK_INPUT ();      return;    }  if (CursorExists) CursorToggle ();  VisibleX = col;  VisibleY = row;  if (!CursorExists) CursorToggle ();  XFlush ();  UNBLOCK_INPUT ();}/* Used to get the terminal back to a known state after resets.  Usually * used when restarting suspended or waiting emacs */staticcleanup (){  inverse_video = 0;  HLmode (0);}/* Erase current line from column cursor_hpos to column END.   Leave cursor at END.  */staticXTclear_end_of_line (end)     register int end;{  register int numcols;#ifdef XDEBUG  fprintf (stderr, "XTclear_end_of_line\n");#endif  if (cursor_vpos < 0 || cursor_vpos >= screen_height)    {      return;    }  if (end >= screen_width)    end = screen_width;  if (end <= cursor_hpos)    return;  numcols = end - cursor_hpos;  {    BLOCK_INPUT_DECLARE ()    BLOCK_INPUT ();    if (cursor_vpos == VisibleY && VisibleX >= cursor_hpos && VisibleX < end)      {	if (CursorExists) CursorToggle ();      }    XPixSet (XXwindow,	     cursor_hpos * fontinfo->width + XXInternalBorder,	     cursor_vpos * fontinfo->height+XXInternalBorder,	     fontinfo->width * numcols,	     fontinfo->height,	     back);    XTmove_cursor (cursor_vpos, end);    UNBLOCK_INPUT ();  }}/* Erase current line from column START to right margin.   Leave cursor at START.  */staticx_clear_end_of_line (start)     register int start;{  register int numcols;#ifdef XDEBUG  fprintf (stderr, "x_clear_end_of_line\n");#endif  if (cursor_vpos < 0 || cursor_vpos >= screen_height)    {      return;    }  if (start < 0)    start = 0;  if (start >= screen_width)    return;  numcols = screen_width - start;  {    BLOCK_INPUT_DECLARE ()    BLOCK_INPUT ();    if (cursor_vpos == VisibleY && VisibleX >= start)      {	if (CursorExists) CursorToggle ();      }    XPixSet (XXwindow,	     start * fontinfo->width + XXInternalBorder,	     cursor_vpos * fontinfo->height+XXInternalBorder,	     fontinfo->width * numcols,	     fontinfo->height,	     back);    XTmove_cursor (cursor_vpos, start);    UNBLOCK_INPUT ();  }}staticXTreset_terminal_modes (){#ifdef XDEBUG  fprintf (stderr, "XTreset_terminal_modes\n");#endif  XTclear_screen ();}staticXTclear_screen (){#ifdef XDEBUG  fprintf (stderr, "XTclear_screen\n");#endif  HLmode (0);  CursorExists = 0;  cursor_hpos = 0;  cursor_vpos = 0;  SavedX = 0;  SavedY = 0;  VisibleX = 0;  VisibleY = 0;  {    BLOCK_INPUT_DECLARE ()    BLOCK_INPUT ();    XClear (XXwindow);    CursorToggle ();    if (!InUpdate)      XFlush ();    UNBLOCK_INPUT ();  }}/* used by dumprectangle which is usually invoked upon ExposeRegion * events which come from bit blt's or moving an obscuring opaque window */staticdumpchars (current_screen, numcols, tempX, tempY, tempHL)     register struct matrix *current_screen;     register int numcols;     register int tempX, tempY, tempHL;{  if (numcols <= 0) return;  if (((numcols - 1) + tempX) > screen_width)    {      numcols = (screen_width - tempX) + 1;    }  if ((tempX < 0) || (tempX >= screen_width) ||      (tempY < 0) || (tempY >= screen_height))    {      return;    }  XText (XXwindow,	 (tempX * fontinfo->width+XXInternalBorder),	 (tempY * fontinfo->height+XXInternalBorder),	 &current_screen->contents[tempY][tempX],	 numcols,	 fontinfo->id,	 (tempHL ? back : fore),	 (tempHL ? fore : back));}/* When a line has been changed this function is called.  X is so fast * that the actual sequence is ignore.  Rather, the new version of the * line is simply output if this function is invoked while in UpDate. * Sometimes writechars can be invoked when not in update if text is to * be output at the end of the line.  In this case the whole line is not * output.  Simply the new text at the current cursor position given * by VisibleX,Y.  The cursor is moved to the end of the new text. */staticwritechars (start, end)     register char *start, *end;{  register int temp_length;  BLOCK_INPUT_DECLARE ()  BLOCK_INPUT ();  if ((cursor_vpos < 0) || (cursor_vpos >= screen_height))    {      UNBLOCK_INPUT ();      return;

⌨️ 快捷键说明

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