} else if (b == MB_SELECT && (a == MA_2CLK || a == MA_3CLK)) {
} else if (b == MBT_SELECT && (a == MA_2CLK || a == MA_3CLK)) {
void term_mouse (Mouse_Button b, Mouse_Action a, int x, int y) {    pos selpoint;    unsigned long *ldata;        if (y<0) y = 0;    if (y>=rows) y = rows-1;    if (x<0) {        if (y > 0) {            x = cols-1;            y--;        } else            x = 0;    }    if (x>=cols) x = cols-1;    selpoint.y = y + disptop;    selpoint.x = x;    ldata = lineptr(selpoint.y);    if ((ldata[cols]&LATTR_MODE) != LATTR_NORM)	selpoint.x /= 2;    if (b == MB_SELECT && a == MA_CLICK) {	deselect();	selstate = ABOUT_TO;	selanchor = selpoint;	selmode = SM_CHAR;    } else if (b == MB_SELECT && (a == MA_2CLK || a == MA_3CLK)) {	deselect();	selmode = (a == MA_2CLK ? SM_WORD : SM_LINE);	selstate = DRAGGING;	selstart = selanchor = selpoint;	selend = selstart;	incpos(selend);	sel_spread();    } else if ((b == MB_SELECT && a == MA_DRAG) ||	       (b == MB_EXTEND && a != MA_RELEASE)) {	if (selstate == ABOUT_TO && poseq(selanchor, selpoint))	    return;	if (b == MB_EXTEND && a != MA_DRAG && selstate == SELECTED) {	    if (posdiff(selpoint,selstart) < posdiff(selend,selstart)/2) {		selanchor = selend;		decpos(selanchor);	    } else {		selanchor = selstart;	    }	    selstate = DRAGGING;	}	if (selstate != ABOUT_TO && selstate != DRAGGING)	    selanchor = selpoint;	selstate = DRAGGING;	if (poslt(selpoint, selanchor)) {	    selstart = selpoint;	    selend = selanchor;	    incpos(selend);	} else {	    selstart = selanchor;	    selend = selpoint;	    incpos(selend);	}	sel_spread();    } else if ((b == MB_SELECT || b == MB_EXTEND) && a == MA_RELEASE) {	if (selstate == DRAGGING) {	    /*	     * We've completed a selection. We now transfer the	     * data to the clipboard.	     */	    clipme(selstart, selend, selspace);	    selstate = SELECTED;	} else	    selstate = NO_SELECTION;    } else if (b == MB_PASTE && (a==MA_CLICK || a==MA_2CLK || a==MA_3CLK)) {	char *data;	int len;	get_clip((void **) &data, &len);	if (data) {	    char *p, *q;	    if (paste_buffer) sfree(paste_buffer);	    paste_pos = paste_hold = paste_len = 0;	    paste_buffer = smalloc(len);	    p = q = data;	    while (p < data+len) {		while (p < data+len &&		       !(p <= data+len-sizeof(sel_nl) &&			 !memcmp(p, sel_nl, sizeof(sel_nl))))		    p++;		{		    int i;		    unsigned char c;		    for(i=0;i<p-q;i++)		    {			c=xlat_kbd2tty(q[i]);			paste_buffer[paste_len++] = c;		    }		}		if (p <= data+len-sizeof(sel_nl) &&		    !memcmp(p, sel_nl, sizeof(sel_nl))) {		    paste_buffer[paste_len++] = '\r';		    p += sizeof(sel_nl);		}		q = p;	    }	    /* Assume a small paste will be OK in one go. */	    if (paste_len<256) {	        ldisc_send (paste_buffer, paste_len);	        if (paste_buffer) sfree(paste_buffer);		paste_buffer = 0;	        paste_pos = paste_hold = paste_len = 0;	    }	}	get_clip(NULL, NULL);    }    term_update();}