Пример #1
0
static void
repaint_line(XtermWidget xw, unsigned newChrSet)
{
    TScreen *screen = TScreenOf(xw);
    LineData *ld;
    int curcol = screen->cur_col;
    int currow = screen->cur_row;
    int width = MaxCols(screen);
    unsigned len = (unsigned) width;

    assert(width > 0);

    /*
     * Ignore repetition.
     */
    if (!IsLeftRightMode(xw)
	&& (ld = getLineData(screen, currow)) != 0) {
	unsigned oldChrSet = GetLineDblCS(ld);

	if (oldChrSet != newChrSet) {
	    TRACE(("repaint_line(%2d,%2d) (%s -> %s)\n", currow, screen->cur_col,
		   visibleDblChrset(oldChrSet),
		   visibleDblChrset(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.  So we paint our own.
	     */
	    ClearCurBackground(xw,
			       currow,
			       0,
			       1,
			       len,
			       (unsigned) LineFontWidth(screen, ld));

	    SetLineDblCS(ld, newChrSet);

	    set_cur_col(screen, 0);
	    ScrnUpdate(xw, currow, 0, 1, (int) len, True);
	    set_cur_col(screen, curcol);
	}
    }
}
Пример #2
0
/*
 * Tab to the next stop, returning true if the cursor moved
 */
Bool
TabToNextStop(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    int saved_column = screen->cur_col;
    int next = TabNext(xw, xw->tabs, screen->cur_col);
    int max = LineMaxCol(screen, getLineData(screen, screen->cur_row));

    if (IsLeftRightMode(xw))
        max = TScreenOf(xw)->rgt_marg;
    if (next > max)
        next = max;
    set_cur_col(screen, next);

    return (screen->cur_col > saved_column);
}
Пример #3
0
/*
 * Moves cursor up amount lines, reverse scrolls if necessary.
 * Won't leave scrolling region. No carriage return.
 */
void
RevIndex(XtermWidget xw, int amount)
{
    TScreen *screen = TScreenOf(xw);

    /*
     * reverse indexing when above scrolling region is cursor up.
     * if cursor low enough, no reverse indexing needed
     */
    if (screen->cur_row < screen->top_marg
	|| screen->cur_row - amount >= screen->top_marg
	|| (IsLeftRightMode(xw)
	    && !ScrnIsColInMargins(screen, screen->cur_col))) {
	CursorUp(screen, amount);
    } else {
	RevScroll(xw, amount - (screen->cur_row - screen->top_marg));
	CursorUp(screen, screen->cur_row - screen->top_marg);
    }
}
Пример #4
0
/*
 * Moves cursor down amount lines, scrolls if necessary.
 * Won't leave scrolling region. No carriage return.
 */
void
xtermIndex(XtermWidget xw, int amount)
{
    TScreen *screen = TScreenOf(xw);
    int j;

    /*
     * indexing when below scrolling region is cursor down.
     * if cursor high enough, no scrolling necessary.
     */
    if (screen->cur_row > screen->bot_marg
	|| screen->cur_row + amount <= screen->bot_marg
	|| (IsLeftRightMode(xw)
	    && !ScrnIsColInMargins(screen, screen->cur_col))) {
	CursorDown(screen, amount);
    } else {
	CursorDown(screen, j = screen->bot_marg - screen->cur_row);
	xtermScroll(xw, amount - j);
    }
}
Пример #5
0
/*
 * moves the cursor forward n, no wraparound
 */
void
CursorForward(XtermWidget xw, int n)
{
    TScreen *screen = TScreenOf(xw);
#if OPT_DEC_CHRSET
    LineData *ld = getLineData(screen, screen->cur_row);
#endif
    int next = screen->cur_col + n;
    int max;

    if (IsLeftRightMode(xw)) {
	max = screen->rgt_marg;
	if (screen->cur_col > max)
	    max = screen->max_col;
    } else {
	max = LineMaxCol(screen, ld);
    }

    if (next > max)
	next = max;

    set_cur_col(screen, next);
    ResetWrap(screen);
}