ComputeSelect(startRow, startCol, endRow, endCol, extend) int startRow, startCol, endRow, endCol; Bool extend;
ComputeSelect( int startRow, int startCol, int endRow, int endCol, Bool extend)
ComputeSelect(startRow, startCol, endRow, endCol, extend)    int startRow, startCol, endRow, endCol;    Bool extend;{	register TScreen *screen = &term->screen;	register Char *ptr;	register int length;	register int class;	int osc = startSCol;	if (Coordinate(startRow, startCol) <= Coordinate(endRow, endCol)) {		startSRow = startRRow = startRow;		startSCol = startRCol = startCol;		endSRow   = endRRow   = endRow;		endSCol   = endRCol   = endCol;	} else {	/* Swap them */		startSRow = startRRow = endRow;		startSCol = startRCol = endCol;		endSRow   = endRRow   = startRow;		endSCol   = endRCol   = startCol;	}		switch (selectUnit) {		case SELECTCHAR :			if (startSCol > (LastTextCol(startSRow) + 1)) {				startSCol = 0;				startSRow++;			}			if (endSCol > (LastTextCol(endSRow) + 1)) {				endSCol = 0;				endSRow++;			}			break;		case SELECTWORD :			if (startSCol > (LastTextCol(startSRow) + 1)) {				startSCol = 0;				startSRow++;			} else {				ptr = SCRN_BUF_CHARS(screen, startSRow+screen->topline)				 + startSCol;				class = charClass[*ptr];				do {					--startSCol;					--ptr;				} while (startSCol >= 0				 && charClass[*ptr] == class);				++startSCol;			}			if (endSCol > (LastTextCol(endSRow) + 1)) {				endSCol = 0;				endSRow++;			} else {				length = LastTextCol(endSRow);				ptr = SCRN_BUF_CHARS(screen, endSRow+screen->topline)				 + endSCol;				class = charClass[*ptr];				do {					++endSCol;					++ptr;				} while (endSCol <= length				 && charClass[*ptr] == class);				/* Word select selects if pointing to any char				   in "word", especially in that it includes				   the last character in a word.  So no --endSCol				   and do special eol handling */				if (endSCol > length+1) {					endSCol = 0;					++endSRow;				}			}			break;		case SELECTLINE :			if (term->screen.cutToBeginningOfLine) {			    startSCol = 0;			} else if (!extend) {			    startSCol = osc;			}			if (term->screen.cutNewline) {			    endSCol = 0;			    ++endSRow;			} else {			    endSCol = LastTextCol(endSRow) + 1;			}			break;	}	TrackText(startSRow, startSCol, endSRow, endSCol);	return;}