view src/=XTests.c @ 21873:3ab8be88f2ef

Generalized region skipping added. Checks comments only in code. Added backward compatible support for customize. (ispell-query-replace-choices, ispell-message-dictionary-alist) (ispell-grep-command, ispell-grep-options, ispell-look-command) (ispell-look-options, ispell-use-ptys-p, ispell-local-dictionary) (ispell-dictionary-alist): Now customizable. Fixed type of custom variables: ispell-help-in-bufferp. (ispell-use-framepop-p): New variable. (ispell-dictionary-alist): Added dictionaries: castellano, castellano8 czech, esperanto, esperanto-tex, norsk, russian. Capitalize XEmacs correctly, and change lucid to xemacs in code: (ispell-menu-lucid): Renamed to ispell-menu-xemacs. Changed string compares for version number to be correct for XEmacs. Fixed to work with string properties. (ispell-recursive-edit-marker): new marker saving return point. (ispell-skip-region-alist): New variable defining regions. (ispell-tex-skip-alists): New variable for LaTeX regions. (ispell-skip-sgml): Now buffer-mode aware. (ispell-highlight-p): Support block cursors. (ispell-message-text-end): Don't check signatures. (ispell-comments-and-strings): New command, added to menu. (ispell-int-char): New function for character incrementing. (ispell-word): Produces message on error when called from ispell-minor-mode. Potential infinite loop removed. (ispell-command-loop): prevent XEmacs modeline hiding. Allow temporary split of dedicated windows. Improve recursive edit support. Support block cursors. (ispell-show-choices): New function cleaning up command loop. (ispell-highlight-spelling-error-generic): Block cursor support added. (ispell-highlight-spelling-error-xemacs): Block cursor, name change. (ispell-overlay-window): dedicated window splitting, XEmacs changes. (ispell-parse-output): Displays ispell process error messages. (check-ispell-version): Interactive mode that shows ispell versions. (ispell-begin-skip-region-regexp): New region skipping function. (ispell-begin-tex-skip-regexp): New tex mode region skipping function. (ispell-begin-skip-region): New region skipping function. (ispell-tex-arg-end): New tex mode region skipping function. (ispell-skip-region): New region skipping function. (ispell-get-line): New function to clean up command loop. (ispell-process-line): New function cleaning up command loop. (ispell-continue): Improve recursive editor support. (ispell-complete-word): Interior fragment support improved. (ispell-message): Region skipping vastly improved.
author Richard M. Stallman <rms@gnu.org>
date Thu, 30 Apr 1998 06:43:48 +0000
parents 3165b2697c78
children
line wrap: on
line source

#include <X11/Xlib.h>
#include <X11/X.h>
#include <X11/Xutil.h>
#include <X11/Xresource.h>
#include "XTests.h"
#include <stdio.h>

static Display *dpy;

static void
quit (dpy)
     Display *dpy;
{
  XCloseDisplay (dpy);
  exit (0);
}

static Colormap screen_colormap;

static unsigned long
obtain_color (color)
     char *color;
{
  int exists;
  XColor color_def;

  if (!screen_colormap)
    screen_colormap = DefaultColormap (dpy, DefaultScreen (dpy));

  exists = XParseColor (dpy, screen_colormap, color, &color_def)
    && XAllocColor (dpy, screen_colormap, &color_def);
  if (exists)
    return color_def.pixel;

  fprintf (stderr, "Can't get color; using black.");
  return BlackPixel (dpy, DefaultScreen (dpy));
}

static char *visual_strings[] =
{
  "StaticGray ",
  "GrayScale  ",
  "StaticColor",
  "PseudoColor",
  "TrueColor  ",
  "DirectColor"
};

main (argc,argv)
     int argc;
     char *argv[];
{
  char *dpy_string;
  int n;
  long mask;
  Visual *my_visual;
  XVisualInfo *vinfo, visual_template;
  XEvent event;
  Window window;
  Screen *scr;
  XGCValues gc_values;
  GC fill_gc, pix_gc, line_xor_gc, line_xor_inv_gc;
  int i;
  int x, y, width, height, geometry, gravity;
  char *geo;
  char default_geo[] = "80x40+0+0";
  int depth;
  Pixmap pix;
  char *string = "Kill the head and the body will die.";
  char dash_list[] = {4, 4};
  int dashes = 2;

  if (argc < 2)
    dpy_string = "localhost:0.0";
  else
    dpy_string = argv[1];

  if (argc >= 3)
    {
      XSizeHints hints;

      printf ("Geometry: %s\t(default: %s)\n", argv[2], default_geo);
      geo = argv[2];
      XWMGeometry (dpy, DefaultScreen (dpy), geo, default_geo,
		   3, &hints, &x, &y, &width, &height, &gravity);
    }

  dpy = XOpenDisplay (dpy_string);
  if (!dpy)
    {
      printf ("Can' open display %s\n", dpy_string);
      exit (1);
    }

  window = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy),
				300, 300, 300, 300, 1,
				BlackPixel (dpy, DefaultScreen (dpy)),
				WhitePixel (dpy, DefaultScreen (dpy)));
  XSelectInput (dpy, window, ButtonPressMask | KeyPressMask
		| EnterWindowMask | LeaveWindowMask);

  gc_values.foreground = obtain_color ("blue");
  gc_values.background = WhitePixel (dpy, DefaultScreen (dpy));
  fill_gc = XCreateGC (dpy, window, GCForeground | GCBackground,
		       &gc_values);

  gc_values.foreground = obtain_color ("red");
  gc_values.line_width = 3;
  gc_values.line_style = LineOnOffDash;
  gc_values.cap_style = CapRound;
  gc_values.join_style = JoinRound;
  line_xor_gc = XCreateGC (dpy, window,
			   GCForeground | GCBackground | GCLineStyle
			   | GCJoinStyle | GCCapStyle | GCLineWidth,
			   &gc_values);
  XSetDashes (dpy, line_xor_gc, 0, dash_list, dashes);

  line_xor_inv_gc = XCreateGC (dpy, window,
			   GCForeground | GCBackground | GCLineWidth,
			   &gc_values);

  depth = DefaultDepthOfScreen (ScreenOfDisplay (dpy, DefaultScreen (dpy)));
  pix = XCreateBitmapFromData (dpy, window, page_glyf_bits,
			       page_glyf_width, page_glyf_height);

  XMapWindow (dpy, window);
  XFlush (dpy);

  while (1)
    {
      XNextEvent (dpy, &event);
      switch (event.type)
	{
	case ButtonPress:
	  switch (event.xbutton.button)
	    {
	    case Button1:
	      XDrawLine (dpy, window, line_xor_gc, 25, 75, 300, 75);
	      break;

	    case Button2:
	      XDrawLine (dpy, window, line_xor_inv_gc, 25, 25, 300, 25);
	      break;

	    case Button3:
	      XDrawLine (dpy, window, line_xor_gc, 25, 25, 25, 125);
	      break;
	    }
	  break;

	case KeyPress:
	  {
	    char buf[20];
	    int n;
	    XComposeStatus status;
	    KeySym keysym;

	    n = XLookupString (&event, buf, 20, &keysym,
			       (XComposeStatus *) &status);

	    if (n == 1 && buf[0] == 'q')
	      quit (dpy);
	  }
	  break;

	case EnterNotify:
	  XCopyPlane (dpy, pix, window, fill_gc, 0, 0,
		      page_glyf_width, page_glyf_height, 100, 100, 1L);
	  XFillRectangle (dpy, window, fill_gc, 50, 50, 50, 50);
	  break;

	case LeaveNotify:
	  XClearWindow (dpy, window);
	  break;
	}

      XFlush (dpy);
    }
}