int topy = -count234(term->scrollback);
int topy = -sblines(term);
static pos sel_spread_half(Terminal *term, pos p, int dir){    unsigned long *ldata;    short wvalue;    int topy = -count234(term->scrollback);    ldata = lineptr(p.y);    switch (term->selmode) {      case SM_CHAR:	/*	 * In this mode, every character is a separate unit, except	 * for runs of spaces at the end of a non-wrapping line.	 */	if (!(ldata[term->cols] & LATTR_WRAPPED)) {	    unsigned long *q = ldata + term->cols;	    while (q > ldata && (q[-1] & CHAR_MASK) == 0x20)		q--;	    if (q == ldata + term->cols)		q--;	    if (p.x >= q - ldata)		p.x = (dir == -1 ? q - ldata : term->cols - 1);	}	break;      case SM_WORD:	/*	 * In this mode, the units are maximal runs of characters	 * whose `wordness' has the same value.	 */	wvalue = wordtype(term, UCSGET(ldata, p.x));	if (dir == +1) {	    while (1) {		int maxcols = (ldata[term->cols] & LATTR_WRAPPED2 ?			       term->cols-1 : term->cols);		if (p.x < maxcols-1) {		    if (wordtype(term, UCSGET(ldata, p.x + 1)) == wvalue)			p.x++;		    else			break;		} else {		    if (ldata[term->cols] & LATTR_WRAPPED) {			unsigned long *ldata2;			ldata2 = lineptr(p.y+1);			if (wordtype(term, UCSGET(ldata2, 0)) == wvalue) {			    p.x = 0;			    p.y++;			    ldata = ldata2;			} else			    break;		    } else			break;		}	    }	} else {	    while (1) {		if (p.x > 0) {		    if (wordtype(term, UCSGET(ldata, p.x - 1)) == wvalue)			p.x--;		    else			break;		} else {		    unsigned long *ldata2;		    int maxcols;		    if (p.y <= topy)			break;		    ldata2 = lineptr(p.y-1);		    maxcols = (ldata2[term->cols] & LATTR_WRAPPED2 ?			      term->cols-1 : term->cols);		    if (ldata2[term->cols] & LATTR_WRAPPED) {			if (wordtype(term, UCSGET(ldata2, maxcols-1))			    == wvalue) {			    p.x = maxcols-1;			    p.y--;			    ldata = ldata2;			} else			    break;		    } else			break;		}	    }	}	break;      case SM_LINE:	/*	 * In this mode, every line is a unit.	 */	p.x = (dir == -1 ? 0 : term->cols - 1);	break;    }    return p;}