Exemple #1
0
MOUSEEVENT *
getmouseevent(void)
{
	static	MOUSEEVENT	m;

	if (mouse == EMACSTERM) {
		switch (mygetch()) {
		case ctrl('_'):		/* click */
			if ((m.button = mygetch()) == '0') { /* if scroll bar */
				m.percent = getpercent();
			} else {
				m.x1 = getcoordinate();
				m.y1 = getcoordinate();
				m.x2 = m.y2 = -1;
			}
			break;

		case ctrl(']'):		/* sweep */
			m.button = mygetch();
			m.x1 = getcoordinate();
			m.y1 = getcoordinate();
			m.x2 = getcoordinate();
			m.y2 = getcoordinate();
			break;
		default:
			return (NULL);
		}
		return (&m);
	}
	return (NULL);
}
Exemple #2
0
MOUSE *
getmouseaction(char leading_char)
{
	static	MOUSE	m;

#if UNIXPC

	if(unixpcmouse == YES && leading_char == ESC) {

		/* Called if cscope received an ESC character.  See if it is
		 * a mouse report and if so, decipher it.  A mouse report
		 * looks like: "<ESC>[?xx;yy;b;rM"
		 */
		int x = 0, y = 0, button = 0, reason = 0;
		int i;
	
		/* Get a mouse report.  The form is: XX;YY;B;RM where
		 * XX is 1,2, or 3 decimal digits with the X pixel position.
		 * Similarly for YY.  B is a single decimal digit with the
		 * button number (4 for one, 2 for two, and 1 for three).
		 * R is the reason for the mouse report.
		 *
		 * In general, the input is read until the mouse report has
		 * been completely read in or we have discovered that this
		 * escape sequence is NOT a mouse report.  In the latter case
		 * return the last character read to the input stream with
		 * myungetch().
		 */
		
		/* Check for "[?" being next 2 chars */
		if(((i = mygetch()) != '[') || ((i = mygetch()) != '?')) {
			myungetch(i);
			return(NULL);
		}
	
		/* Grab the X position (in pixels) */
		while(isdigit(i = mygetch())) {
			x = (x*10) + (i - '0');
		}
		if(i != ';') {
			myungetch(i);
			return(NULL);	/* not a mouse report after all */
		}
	
		/* Grab the Y position (in pixels) */
		while(isdigit(i = mygetch())) {
			y = (y*10) + (i - '0');
		}
		if(i != ';') {
			myungetch(i);
			return(NULL);
		}
	
		/* Get which button */
		if((button = mygetch()) > '4') {
			myungetch(button);
			return(NULL);
		}
		if((i = mygetch()) != ';') {
			myungetch(i);
			return(NULL);
		}
		
		/* Get the reason for this mouse report */
		if((reason = mygetch()) > '8') {
			myungetch(reason);
			return(NULL);
		}
		
		/* sequence should terminate with an 'M' */
		if((i = mygetch()) != 'M') {
			myungetch(i);
			return(NULL);
		}
	
	
		/* OK.  We get a mouse report whenever a button is depressed
		 * or released.  Let's ignore the report whenever the button
		 * is depressed until when I am ready to implement sweeping.
		 */
		if(reason != '2') {
			return(NULL);	/* '2' means button is released */
		}
	
		/************************************************************
		 * Always indicate button 1 irregardless of which button was
		 * really pushed.
		 ************************************************************/
		m.button = 1;
	
		/************************************************************
		 * Convert pixel coordinates to line and column coords.
		 * The height and width are obtained using an ioctl() call
		 * in mouseinit().  This assumes that variable width chars
		 * are not being used ('though it would probably work anyway).
		 ************************************************************/
		
		m.x1 = x/uw_hs;	/* pixel/horizontal_spacing */
		m.y1 = y/uw_vs;	/* pixel/vertical_spacing   */
	
		/* "null" out the other fields */
		m.percent = m.x2 = m.y2 = -1;
	}
	else
#endif	/* not UNIXPC */

	if (mouse == YES && leading_char == ctrl('X')) {
	
		switch (mygetch()) {
		case ctrl('_'):		/* click */
			if ((m.button = mygetch()) == '0') {	/* if scrollbar */
				m.percent = getpercent();
			}
			else {
				m.x1 = getcoordinate();
				m.y1 = getcoordinate();
				m.x2 = m.y2 = -1;
			}
			break;
	
		case ctrl(']'):		/* sweep */
			m.button = mygetch();
			m.x1 = getcoordinate();
			m.y1 = getcoordinate();
			m.x2 = getcoordinate();
			m.y2 = getcoordinate();
			break;
		default:
			return(NULL);
		}
	}
	else return(NULL);

	return(&m);
}