Beispiel #1
0
void LCDisplayLineWrap(Layer *l, struct mline *ml, int y, int from, int to, int isblank)
{
	struct mchar nc;
	copy_mline2mchar(&nc, ml, 0);
	if (dw_left(ml, 0, l->l_encoding)) {
		nc.mbcs = ml->image[1];
		from++;
	}
	LWrapChar(l, &nc, y - 1, -1, -1, false);
	from++;
	if (from <= to)
		LCDisplayLine(l, ml, y, from, to, isblank);
}
Beispiel #2
0
void LInsChar(Layer *l, struct mchar *c, int x, int y, struct mline *ol)
{
	int xs2, xe2, y2, f;
	struct mchar *c2, cc;
	struct mline *rol;

	if (l->l_pause.d)
		LayPauseUpdateRegion(l, x, l->l_width - 1, y, y);
	for (Canvas *cv = l->l_cvlist; cv; cv = cv->c_lnext) {
		if (l->l_pause.d && cv->c_slorient)
			continue;
		for (Viewport *vp = cv->c_vplist; vp; vp = vp->v_next) {
			y2 = y + vp->v_yoff;
			if (y2 < vp->v_ys || y2 > vp->v_ye)
				continue;
			xs2 = x + vp->v_xoff;
			xe2 = l->l_width - 1 + vp->v_xoff;
			c2 = c;
			f = 0;
			if (xs2 < vp->v_xs) {
				xs2 = vp->v_xs;
				c2 = &mchar_blank;
				if (ol) {
					int i;
					i = xs2 - vp->v_xoff - 1;
					if (i >= 0 && i < l->l_width) {
						copy_mline2mchar(&cc, ol, i);
						c2 = &cc;
					}
				} else
					f = 1;
			}
			if (xe2 > vp->v_xe)
				xe2 = vp->v_xe;
			if (xs2 > xe2)
				continue;
			display = cv->c_display;
			if (D_blocked)
				continue;
			rol = RECODE_MLINE(ol);
			InsChar(RECODE_MCHAR(c2), xs2, xe2, y2, mlineoffset(rol, -vp->v_xoff));
			if (f)
				RefreshArea(xs2, y2, xs2, y2, 1);
		}
	}
}
Beispiel #3
0
Datei: mark.c Projekt: meh/screen
/* tx, ty: WINDOW,  line: DISPLAY */
void revto_line(int tx, int ty, int line)
{
	int fx, fy;
	int x, y, t, revst, reven, qq, ff, tt, st, en, ce = 0;
	int ystart = 0, yend = fore->w_height - 1;
	int i, ry;
	uint32_t *wi;
	struct mline *ml;
	struct mchar mc;

	if (tx < 0)
		tx = 0;
	else if (tx > fore->w_width - 1)
		tx = fore->w_width - 1;
	if (ty < 0)
		ty = 0;
	else if (ty > fore->w_histheight + fore->w_height - 1)
		ty = fore->w_histheight + fore->w_height - 1;

	fx = markdata->cx;
	fy = markdata->cy;

	/* don't just move inside of a kanji, the user wants to see something */
	ml = WIN(ty);
	if (ty == fy && fx + 1 == tx && dw_right(ml, tx, fore->w_encoding) && tx < D_width - 1)
		tx++;
	if (ty == fy && fx - 1 == tx && dw_right(ml, fx, fore->w_encoding) && tx)
		tx--;

	markdata->cx = tx;
	markdata->cy = ty;

	/*
	 * if we go to a position that is currently offscreen
	 * then scroll the screen
	 */
	i = 0;
	if (line >= 0 && line < fore->w_height)
		i = W2D(ty) - line;
	else if (ty < markdata->hist_offset)
		i = ty - markdata->hist_offset;
	else if (ty > markdata->hist_offset + (fore->w_height - 1))
		i = ty - markdata->hist_offset - (fore->w_height - 1);
	if (i > 0)
		yend -= MarkScrollUpDisplay(i);
	else if (i < 0)
		ystart += MarkScrollDownDisplay(-i);

	if (markdata->second == 0) {
		flayer->l_x = tx;
		flayer->l_y = W2D(ty);
		LGotoPos(flayer, tx, W2D(ty));
		return;
	}

	qq = markdata->x1 + markdata->y1 * fore->w_width;
	ff = fx + fy * fore->w_width;	/* "from" offset in WIN coords */
	tt = tx + ty * fore->w_width;	/* "to" offset  in WIN coords */

	if (ff > tt) {
		st = tt;
		en = ff;
		x = tx;
		y = ty;
	} else {
		st = ff;
		en = tt;
		x = fx;
		y = fy;
	}
	if (st > qq) {
		st++;
		x++;
	}
	if (en < qq)
		en--;
	if (tt > qq) {
		revst = qq;
		reven = tt;
	} else {
		revst = tt;
		reven = qq;
	}
	ry = y - markdata->hist_offset;
	if (ry < ystart) {
		y += (ystart - ry);
		x = 0;
		st = y * fore->w_width;
		ry = ystart;
	}
	ml = WIN(y);
	for (t = st; t <= en; t++, x++) {
		if (x >= fore->w_width) {
			x = 0;
			y++, ry++;
			ml = WIN(y);
		}
		if (ry > yend)
			break;
		if (t == st || x == 0) {
			wi = ml->image + fore->w_width;
			for (ce = fore->w_width; ce >= 0; ce--, wi--)
				if (*wi != ' ')
					break;
		}
		if (x <= ce && x >= markdata->left_mar && x <= markdata->right_mar) {
			if (dw_right(ml, x, fore->w_encoding)) {
				if (t == revst)
					revst--;
				t--;
				x--;
			}
			if (t >= revst && t <= reven) {
				mc = mchar_so;
				if (pastefont) {
					mc.font = ml->font[x];
					mc.fontx = ml->fontx[x];
				}
				mc.image = ml->image[x];
			} else
				copy_mline2mchar(&mc, ml, x);
			if (dw_left(ml, x, fore->w_encoding)) {
				mc.mbcs = ml->image[x + 1];
				LPutChar(flayer, &mc, x, W2D(y));
				t++;
			}
			LPutChar(flayer, &mc, x, W2D(y));
			if (dw_left(ml, x, fore->w_encoding))
				x++;
		}
	}
	flayer->l_x = tx;
	flayer->l_y = W2D(ty);
	LGotoPos(flayer, tx, W2D(ty));
}