Ejemplo n.º 1
0
/*
 * Move the cursor to the first column of the n-th previous line.
 */
void
CursorPrevLine(TScreen *screen, int count)
{
	CursorUp(screen, count < 1 ? 1 : count);
	CarriageReturn(screen);
	do_xevents();
}
Ejemplo n.º 2
0
/*
 * moves the cursor left n, no wrap around
 */
void
CursorBack(XtermWidget xw, int n)
{
#define WRAP_MASK (REVERSEWRAP | WRAPAROUND)
    TScreen *screen = TScreenOf(xw);
    int offset, in_row, length, rev;
    int left = ScrnLeftMargin(xw);
    int before = screen->cur_col;

    if ((rev = (xw->flags & WRAP_MASK) == WRAP_MASK) != 0
	&& screen->do_wrap) {
	n--;
    }

    /* if the cursor is already before the left-margin, we have to let it go */
    if (before < left)
	left = 0;

    if ((screen->cur_col -= n) < left) {
	if (rev) {
	    in_row = ScrnRightMargin(xw) - left + 1;
	    offset = (in_row * screen->cur_row) + screen->cur_col - left;
	    if (offset < 0) {
		length = in_row * MaxRows(screen);
		offset += ((-offset) / length + 1) * length;
	    }
	    set_cur_row(screen, (offset / in_row));
	    set_cur_col(screen, (offset % in_row) + left);
	    do_xevents();
	} else {
	    set_cur_col(screen, left);
	}
    }
    ResetWrap(screen);
}
Ejemplo n.º 3
0
/*
 * Move the cursor to the first column of the n-th next line.
 */
void
CursorNextLine(TScreen *screen, int count)
{
	CursorDown(screen, count < 1 ? 1 : count);
	CarriageReturn(screen);
	do_xevents();
}
Ejemplo n.º 4
0
/*
 * Move the cursor to the first column of the n-th previous line.
 */
void
CursorPrevLine(XtermWidget xw, int count)
{
    TScreen *screen = TScreenOf(xw);

    CursorUp(screen, count < 1 ? 1 : count);
    CarriageReturn(xw);
    do_xevents();
}
Ejemplo n.º 5
0
/*
 * Moves Cursor To First Column In Line
 * (Note: xterm doesn't implement SLH, SLL which would affect use of this)
 */
void
CarriageReturn(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    int left = ScrnLeftMargin(xw);
    int col;

    if (xw->flags & ORIGIN) {
	col = left;
    } else if (screen->cur_col >= left) {
	col = left;
    } else {
	/*
	 * If origin-mode is not active, it is possible to use cursor
	 * addressing outside the margins.  In that case we will go to the
	 * first column rather than following the margin.
	 */
	col = 0;
    }

    set_cur_col(screen, col);
    ResetWrap(screen);
    do_xevents();
}