void
WindowScroll(XtermWidget xw, int top, Bool always GCC_UNUSED)
{
    TScreen *screen = TScreenOf(xw);

#if OPT_SCROLL_LOCK
    if (screen->allowScrollLock && (screen->scroll_lock && !always)) {
	if (screen->scroll_dirty) {
	    screen->scroll_dirty = False;
	    ScrnRefresh(xw, 0, 0, MaxRows(screen), MaxCols(screen), False);
	}
    } else
#endif
    {
	int i;

	if (top < -screen->savedlines) {
	    top = -screen->savedlines;
	} else if (top > 0) {
	    top = 0;
	}

	if ((i = screen->topline - top) != 0) {
	    int lines;
	    int scrolltop, scrollheight, refreshtop;

	    if (screen->cursor_state)
		HideCursor();
	    lines = i > 0 ? i : -i;
	    if (lines > MaxRows(screen))
		lines = MaxRows(screen);
	    scrollheight = screen->max_row - lines + 1;
	    if (i > 0)
		refreshtop = scrolltop = 0;
	    else {
		scrolltop = lines;
		refreshtop = scrollheight;
	    }
	    scrolling_copy_area(xw, scrolltop, scrollheight, -i);
	    screen->topline = top;

	    ScrollSelection(screen, i, True);

	    xtermClear2(xw,
			OriginX(screen),
			OriginY(screen) + refreshtop * FontHeight(screen),
			(unsigned) Width(screen),
			(unsigned) (lines * FontHeight(screen)));
	    ScrnRefresh(xw, refreshtop, 0, lines, MaxCols(screen), False);

#if OPT_BLINK_CURS || OPT_BLINK_TEXT
	    RestartBlinking(screen);
#endif
	}
    }
    ScrollBarDrawThumb(screen->scrollWidget);
}
Exemple #2
0
static void
repaint_line(unsigned newChrSet)
{
	register TScreen *screen = &term->screen;
	int curcol = screen->cur_col;
	int len = screen->max_col + 1;
	int width = len;

	TRACE(("repaint_line(%2d,%2d) (%d)\n", screen->cur_row, screen->cur_col, newChrSet))

	/* If switching from single-width, keep the cursor in the visible part
	 * of the line.
	 */
	if (CSET_DOUBLE(newChrSet)) {
		width /= 2;
		if (curcol > width)
			curcol = width;
	}

	/* FIXME: do VT220 softchars allow double-sizes? */
	memset(SCRN_BUF_CSETS(screen, screen->cur_row), newChrSet, len);

	screen->cur_col = 0;
	ScrnRefresh (screen, screen->cur_row, 0, 1, len, True);
	screen->cur_col = curcol;
}
void WindowScroll(TScreen *screen,int top)
{
    register int i, lines;
    register int scrolltop, scrollheight, refreshtop;
    register int x = 0;

    if (top < -screen->savedlines)
        top = -screen->savedlines;
    else if (top > 0)
        top = 0;
    if((i = screen->topline - top) == 0)
    {
        ScrollBarDrawThumb(screen->scrollWidget);
        return;
    }

    /*ScrollSelection(screen, i);*/

    if(screen->cursor_state)
        HideCursor();
    lines = i > 0 ? i : -i;
    if(lines > screen->max_row + 1)
        lines = screen->max_row + 1;
    scrollheight = screen->max_row - lines + 1;
    if(i > 0)
        refreshtop = scrolltop = 0;
    else
    {
        scrolltop = lines;
        refreshtop = scrollheight;
    }
    /*x = screen->scrollbar + screen->border;*/
    x=OriginX(screen);

    scrolling_copy_area(screen, scrolltop, scrollheight, -i);
    screen->topline = top;

    ScrollSelection(screen, i);

    XClearArea(
        screen->display,
        /*TextWindow(screen),*/
        VWindow(screen),
        (int) x,
        (int) refreshtop * FontHeight(screen) + screen->border,
        (unsigned) Width(screen),
        (unsigned) lines * FontHeight(screen),
        FALSE);
    ScrnRefresh(screen, refreshtop, 0, lines, screen->max_col + 1, False);

    ScrollBarDrawThumb(screen->scrollWidget);
}
Exemple #4
0
/*
 * After writing text to the screen, resolve mismatch between the current
 * location and any attributes that would have been set by preceding locations.
 */
void Resolve_XMC(register TScreen *screen)
{
	Boolean changed = False;
	Char start;
	Char my_attrs = (screen->xmc_attributes & XMC_FLAGS);
	int row = screen->cur_row;
	int col = screen->cur_col;

	/* Find the preceding cell.
	 */
	if (getXtermCell(screen, row, col) != XMC_GLITCH) {
		if (col != 0) {
			col--;
		} else if (!screen->xmc_inline && row != 0) {
			row--;
			col = CurMaxCol(screen, row);
		}
	}
	start = (SCRN_BUF_ATTRS(screen, row)[col] & my_attrs);

	/* Now propagate the starting state until we reach a cell which holds
	 * a glitch.
	 */
	for (;;) {
		if (col < CurMaxCol(screen, row)) {
			col++;
		} else if (!screen->xmc_inline && row < screen->max_row) {
			row++;
			col = 0;
		} else
			break;
		if (getXtermCell(screen, row, col) == XMC_GLITCH)
			break;
		if ((SCRN_BUF_ATTRS(screen, row)[col] & my_attrs) != start) {
			SCRN_BUF_ATTRS(screen, row)[col] = start |
				(SCRN_BUF_ATTRS(screen, row)[col] & ~my_attrs);
			changed = True;
		}
	}

	TRACE(("XMC %s (%s:%d/%d) from %d,%d to %d,%d\n",
		changed ? "Ripple" : "Nochange",
		term->flags & my_attrs ? "on" : "off",
		my_attrs, start,
		screen->cur_row, screen->cur_col, row, col));

	if (changed) {
		ScrnRefresh (screen, screen->cur_row, 0, row + 1 - screen->cur_row, screen->max_col + 1, True);
	}
}
Exemple #5
0
static void
repaint_line(unsigned newChrSet)
{
    register TScreen *screen = &term->screen;
    int curcol = screen->cur_col;
    int currow = screen->cur_row;
    int len = screen->max_col + 1;
    int width = len;
    unsigned oldChrSet = SCRN_BUF_CSETS(screen, currow)[0];

    /*
     * Ignore repetition.
     */
    if (oldChrSet == newChrSet)
	return;

    TRACE(("repaint_line(%2d,%2d) (%d)\n", currow, screen->cur_col, newChrSet));
    HideCursor();

    /* If switching from single-width, keep the cursor in the visible part
     * of the line.
     */
    if (CSET_DOUBLE(newChrSet)) {
	width /= 2;
	if (curcol > width)
	    curcol = width;
    }

    /*
     * ScrnRefresh won't paint blanks for us if we're switching between a
     * single-size and double-size font.
     */
    if (CSET_DOUBLE(oldChrSet) != CSET_DOUBLE(newChrSet)) {
	ClearCurBackground(
			      screen,
			      CursorY(screen, currow),
			      CurCursorX(screen, currow, 0),
			      FontHeight(screen),
			      len * CurFontWidth(screen, currow));
    }

    /* FIXME: do VT220 softchars allow double-sizes? */
    memset(SCRN_BUF_CSETS(screen, currow), newChrSet, len);

    screen->cur_col = 0;
    ScrnRefresh(screen, currow, 0, 1, len, True);
    screen->cur_col = curcol;
}
Exemple #6
0
/*
 * These routines are used for the jump scroll feature
 */
void
FlushScroll(register TScreen *screen)
{
	register int i;
	register int shift = -screen->topline;
	register int bot = screen->max_row - shift;
	register int refreshtop;
	register int refreshheight;
	register int scrolltop;
	register int scrollheight;

	if(screen->cursor_state)
		HideCursor();
	if(screen->scroll_amt > 0) {
		refreshheight = screen->refresh_amt;
		scrollheight = screen->bot_marg - screen->top_marg -
		 refreshheight + 1;
		if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) >
		 (i = screen->max_row - screen->scroll_amt + 1))
			refreshtop = i;
		if(screen->scrollWidget && !screen->alternate
		 && screen->top_marg == 0) {
			scrolltop = 0;
			if((scrollheight += shift) > i)
				scrollheight = i;
			if((i = screen->bot_marg - bot) > 0 &&
			 (refreshheight -= i) < screen->scroll_amt)
				refreshheight = screen->scroll_amt;
			if((i = screen->savedlines) < screen->savelines) {
				if((i += screen->scroll_amt) >
				  screen->savelines)
					i = screen->savelines;
				screen->savedlines = i;
				ScrollBarDrawThumb(screen->scrollWidget);
			}
		} else {
			scrolltop = screen->top_marg + shift;
			if((i = bot - (screen->bot_marg - screen->refresh_amt +
			 screen->scroll_amt)) > 0) {
				if(bot < screen->bot_marg)
					refreshheight = screen->scroll_amt + i;
			} else {
				scrollheight += i;
				refreshheight = screen->scroll_amt;
				if((i = screen->top_marg + screen->scroll_amt -
				 1 - bot) > 0) {
					refreshtop += i;
					refreshheight -= i;
				}
			}
		}
	} else {
		refreshheight = -screen->refresh_amt;
		scrollheight = screen->bot_marg - screen->top_marg -
		 refreshheight + 1;
		refreshtop = screen->top_marg + shift;
		scrolltop = refreshtop + refreshheight;
		if((i = screen->bot_marg - bot) > 0)
			scrollheight -= i;
		if((i = screen->top_marg + refreshheight - 1 - bot) > 0)
			refreshheight -= i;
	}
	scrolling_copy_area(screen, scrolltop+screen->scroll_amt,
			    scrollheight, screen->scroll_amt);
	ScrollSelection(screen, -(screen->scroll_amt));
	screen->scroll_amt = 0;
	screen->refresh_amt = 0;
	if(refreshheight > 0) {
		ClearCurBackground(screen,
		    (int) refreshtop * FontHeight(screen) + screen->border,
		    (int) OriginX(screen),
		    (unsigned) refreshheight * FontHeight(screen),
		    (unsigned) Width(screen));
		ScrnRefresh(screen, refreshtop, 0, refreshheight,
		    screen->max_col + 1, False);
	}
}
Exemple #7
0
/*
 * scrolls the screen by amount lines, erases bottom, doesn't alter
 * cursor position (i.e. cursor moves down amount relative to text).
 * All done within the scrolling region, of course.
 * requires: amount > 0
 */
void
Scroll(register TScreen *screen, register int amount)
{
	register int i = screen->bot_marg - screen->top_marg + 1;
	register int shift;
	register int bot;
	register int refreshtop = 0;
	register int refreshheight;
	register int scrolltop;
	register int scrollheight;

	if(screen->cursor_state)
		HideCursor();
	if (amount > i)
		amount = i;
    if(screen->jumpscroll) {
	if(screen->scroll_amt > 0) {
		if(screen->refresh_amt + amount > i)
			FlushScroll(screen);
		screen->scroll_amt += amount;
		screen->refresh_amt += amount;
	} else {
		if(screen->scroll_amt < 0)
			FlushScroll(screen);
		screen->scroll_amt = amount;
		screen->refresh_amt = amount;
	}
	refreshheight = 0;
    } else {
	ScrollSelection(screen, -(amount));
	if (amount == i) {
		ClearScreen(screen);
		return;
	}
	shift = -screen->topline;
	bot = screen->max_row - shift;
	scrollheight = i - amount;
	refreshheight = amount;
	if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) >
	 (i = screen->max_row - refreshheight + 1))
		refreshtop = i;
	if(screen->scrollWidget && !screen->alternate
	 && screen->top_marg == 0) {
		scrolltop = 0;
		if((scrollheight += shift) > i)
			scrollheight = i;
		if((i = screen->savedlines) < screen->savelines) {
			if((i += amount) > screen->savelines)
				i = screen->savelines;
			screen->savedlines = i;
			ScrollBarDrawThumb(screen->scrollWidget);
		}
	} else {
		scrolltop = screen->top_marg + shift;
		if((i = screen->bot_marg - bot) > 0) {
			scrollheight -= i;
			if((i = screen->top_marg + amount - 1 - bot) >= 0) {
				refreshtop += i;
				refreshheight -= i;
			}
		}
	}

	if (screen->multiscroll && amount == 1 &&
	    screen->topline == 0 && screen->top_marg == 0 &&
	    screen->bot_marg == screen->max_row) {
	    if (screen->incopy < 0 && screen->scrolls == 0)
		CopyWait(screen);
	    screen->scrolls++;
	}
	scrolling_copy_area(screen, scrolltop+amount, scrollheight, amount);
	if(refreshheight > 0) {
		ClearCurBackground(screen,
		    (int) refreshtop * FontHeight(screen) + screen->border,
		    (int) OriginX(screen),
		    (unsigned) refreshheight * FontHeight(screen),
		    (unsigned) Width(screen));
		if(refreshheight > shift)
			refreshheight = shift;
	}
    }
	if(screen->scrollWidget && !screen->alternate && screen->top_marg == 0)
		ScrnDeleteLine(screen, screen->allbuf,
			screen->bot_marg + screen->savelines, 0,
			amount, screen->max_col + 1);
	else
		ScrnDeleteLine(screen, screen->visbuf,
			screen->bot_marg, screen->top_marg,
			amount, screen->max_col + 1);
	if(refreshheight > 0)
		ScrnRefresh(screen, refreshtop, 0, refreshheight,
		 screen->max_col + 1, False);
}