Exemple #1
0
/*
 * Clear from cursor position to beginning of display, inclusive.
 */
static void
ClearAbove (register TScreen *screen)
{
	if (screen->protected_mode != OFF_PROTECT) {
		register int row;
		for (row = 0; row <= screen->max_row; row++)
			ClearInLine(screen, row, 0, screen->max_col + 1);
	} else {
		register int top, height;

		if(screen->cursor_state)
			HideCursor();
		if((top = -screen->topline) <= screen->max_row) {
			if(screen->scroll_amt)
				FlushScroll(screen);
			if((height = screen->cur_row + top) > screen->max_row)
				height = screen->max_row;
			if((height -= top) > 0) {
				ClearCurBackground(screen,
				    top * FontHeight(screen) + screen->border,
				    OriginX(screen),
				    height * FontHeight(screen),
				    Width(screen));
			}
		}
		ClearBufRows(screen, 0, screen->cur_row - 1);
	}

	if(screen->cur_row - screen->topline <= screen->max_row)
		ClearLeft(screen);
}
Exemple #2
0
/*
 * Clear from cursor position to end of display, inclusive.
 */
static void
ClearBelow (register TScreen *screen)
{
	ClearRight(screen, -1);

	if (screen->protected_mode != OFF_PROTECT) {
		register int row;
		for (row = screen->cur_row + 1; row <= screen->max_row; row++)
			ClearInLine(screen, row, 0, screen->max_col + 1);
	} else {
		register int top;

		if((top = screen->cur_row - screen->topline) <= screen->max_row) {
			if(screen->scroll_amt)
				FlushScroll(screen);
			if(++top <= screen->max_row) {
				ClearCurBackground(screen,
				    top * FontHeight(screen) + screen->border,
				    OriginX(screen),
				    (screen->max_row - top + 1) * FontHeight(screen),
				    Width(screen));
			}
		}
		ClearBufRows(screen, screen->cur_row + 1, screen->max_row);
	}
}
Exemple #3
0
/*
 * Reverse scrolls the screen by amount lines, erases top, doesn't alter
 * cursor position (i.e. cursor moves up amount relative to text).
 * All done within the scrolling region, of course.
 * Requires: amount > 0
 */
void
RevScroll(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;
	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;
	}
    } else {
	shift = -screen->topline;
	bot = screen->max_row - shift;
	refreshheight = amount;
	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;

	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));
	}
    }
    ScrnInsertLine(screen, screen->visbuf, screen->bot_marg, screen->top_marg,
		   amount, screen->max_col + 1);
}
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);
}
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 #6
0
/*
 * If cursor not in scrolling region, returns.  Else,
 * inserts n blank lines at the cursor's position.  Lines above the
 * bottom margin are lost.
 */
void
InsertLine (register TScreen *screen, register int n)
{
	register int i;
	register int shift;
	register int bot;
	register int refreshtop;
	register int refreshheight;
	register int scrolltop;
	register int scrollheight;

	if (screen->cur_row < screen->top_marg ||
	 screen->cur_row > screen->bot_marg)
		return;
	if(screen->cursor_state)
		HideCursor();
	screen->do_wrap = 0;
	if (n > (i = screen->bot_marg - screen->cur_row + 1))
		n = i;
    if(screen->jumpscroll) {
	if(screen->scroll_amt <= 0 &&
	 screen->cur_row <= -screen->refresh_amt) {
		if(-screen->refresh_amt + n > screen->max_row + 1)
			FlushScroll(screen);
		screen->scroll_amt -= n;
		screen->refresh_amt -= n;
	} else if(screen->scroll_amt)
		FlushScroll(screen);
    }
    if(!screen->scroll_amt) {
	shift = -screen->topline;
	bot = screen->max_row - shift;
	refreshheight = n;
	scrollheight = screen->bot_marg - screen->cur_row - refreshheight + 1;
	refreshtop = screen->cur_row + shift;
	scrolltop = refreshtop + refreshheight;
	if((i = screen->bot_marg - bot) > 0)
		scrollheight -= i;
	if((i = screen->cur_row + refreshheight - 1 - bot) > 0)
		refreshheight -= i;
	vertical_copy_area(screen, scrolltop-n, scrollheight, -n);
	if(refreshheight > 0) {
		ClearCurBackground(screen,
		    (int) refreshtop * FontHeight(screen) + screen->border,
		    (int) OriginX(screen),
		    (unsigned) refreshheight * FontHeight(screen),
		    (unsigned) Width(screen));
	}
    }
    ScrnInsertLine(screen, screen->visbuf, screen->bot_marg, screen->cur_row, n,
		   screen->max_col + 1);
}
BOOL DTM2D::DrawContours(CONTOUR_MAP *ctr)
{

	/**************************************************************************
	*
	*  function name: draw_contours
	*
	*     Generates a contour map from a gridded DTM.  Does not produce vector
	*     information, only a plot on screen.
	*
	*     Reference:
	*
	*        Chris Johnston 1986
	*        Contour plots of large data sets.
	*        Computer Language.
	*        May 1986.
	*
	*
	*     cell vertex and side numbering
	*
	*        2----------1----------3
	*        | \                 / |
	*        |   \             /   |
	*        |     5         6     |
	*        |       \     /       |
	*        0         \ /         2
	*        |         / \         |
	*        |       /     \       |
	*        |     4         7     |
	*        |   /             \   |
	*        | /                 \ |
	*        1----------3----------0
	*  description:
	*
	*     Given a dtm file name, contour interval information, colors, and
	*     the desired area within the DTM, draw contours() draws the contour
	*     lines for the dtm unit.  Assumes that all screen scaling and
	*     windowing has already been done.
	*
	*  return value:
	*
	*     Returns 0 to indicate success, -1 to indicate error.
	*
	**************************************************************************/

	long i;                          // loop counter 
	long j;                          // loop counter 
	int l;                           // loop counter for contour levels 
	int start_level;                 // starting contour level for a column 
	int end_level;                   // ending contour level for a column 
	int k;                           // loop counter for cell side crossings 
	int flag;                        // flag to control pen status (up or down) 
	int cell_index;                  // index into edge crossing array 
	int exit_key = 0;				 // keystroke...only [Esc] terminates 
	long start_col;                  // starting column to be contoured 
	long stop_col;                   // ending column to be contoured 
	long start_point;                // starting point to be contoured 
	long stop_point;                 // ending point to be contoured 
	long test_point;				 // temporary value for testing end of grid 
	long leftover_col;               // extra columns not contoured on first pass 
	long leftover_point;             // extra points not contoured on first pass 
	float ave_elev;                  // average elevation of a cell 
	float x_mult = 1.0f;             // relative distance along a cell edge in X 
	float y_mult = 1.0f;             // relative distance along a cell edge in Y 
	double column_x;                 // X coordinate of column (left side) 
	double x, y;					 // point on line
	void *e1 = NULL;                // pointer to array of elevation data 
	void *e2 = NULL;                // pointer to array of elevation data 
	void *temp = NULL;              // temporary...used when swapping e1 and e2 
	POINT pt;						 // screen point
	CONTOUR_MAP temp_ctr;			 // CONTOUR_MAP structure used for recursive calls 
	MSG stopmsg;
	WCS wcs;

	if (!Valid)
		return(FALSE);

	// set up scaling using WCS
	wcs.Scale(ctr->pDC, ctr->world_ll.x, ctr->world_ll.y, ctr->world_ur.x, ctr->world_ur.y);
	wcs.IsoAdjust(ctr->pDC);

	// calculate the starting row and column 
	start_col = (long) floor((ctr->lower_left.x - Header.origin_x) / Header.column_spacing);
	stop_col = (long) ceil((ctr->upper_right.x - Header.origin_x) / Header.column_spacing);
	start_point = (long) floor((ctr->lower_left.y - Header.origin_y) / Header.point_spacing);
	stop_point = (long) ceil((ctr->upper_right.y - Header.origin_y) / Header.point_spacing);

	if (start_col < 0)
		start_col = 0;
	if (stop_col > (Header.columns - 1))
		stop_col = Header.columns - 1;
	if (start_point < 0)
		start_point = 0;
	if (stop_point > (Header.points - 1))
		stop_point = Header.points - 1;

	// if we have elevations in memory, work from memory
	if (HaveElevations) {
		e2 = lpsElevData[start_col];
	}
	else {
		int sizes[] = {sizeof(short), sizeof(int), sizeof(float), sizeof(double)};

		// otherwise read from file
		// open the dtm file 
		if (!OpenModelFile())
			return(FALSE);

		// allocate memory for 2 profiles of dtm data 
		e1 = (void *) malloc((size_t) Header.points * sizes[Header.z_bytes]);

		// check for allocation problems 
		if (!e1) {
			CloseModelFile();

			return(FALSE);
		}

		e2 = (void *) malloc((size_t) Header.points * sizes[Header.z_bytes]);

		// check for allocation problems 
		if (!e2) {
			free(e1);
			CloseModelFile();

			return(FALSE);
		}

		// read the first profile into e2...will be swapped to e1 in loop 
		if (LoadDTMProfile(start_col, e2)) {
			free(e1);
			free(e2);
			CloseModelFile();

			return(FALSE);
		}
	}

	// sweep through the cells and draw contours 
	for (i = start_col; i < stop_col; i += ctr->column_smooth) {
		// check for last column 
		if (i + ctr->column_smooth > stop_col)
			break;

		// calculate the x for the column 
		column_x = Header.origin_x + ((double) i * Header.column_spacing);

		// swap pointers to elevation arrays 
		temp = e1;
		e1 = e2;
		e2 = temp;

		// read next profile 
		if (HaveElevations) 
			e2 = lpsElevData[i + ctr->column_smooth];
		else {
			if (LoadDTMProfile(i + ctr->column_smooth, e2)) {
				free(e1);
				free(e2);
				CloseModelFile();

				return(FALSE);
			}
		}

		// set color for normal interval 
		ctr->pDC->SelectObject(ctr->cpNormalPen);

		// calculate test point for end of data 
		test_point = stop_point - ctr->point_smooth;

		for (j = start_point; j < stop_point; j += ctr->point_smooth) {
			// check for last point 
			if (j > test_point)
				break;

			if (!ctr->DrawZeroLine) {
				// check for 1 or more void area markers (-1) and skip cell 
				if (ReadColumnValue(e1, j) < 0 || ReadColumnValue(e2, j) < 0 || ReadColumnValue(e1, j+ ctr->point_smooth) < 0 || ReadColumnValue(e2, j + ctr->point_smooth) < 0)
					continue;
			}

			// determine cell min/max elevations 
			start_level = (int) __min(ReadColumnValue(e1, j), ReadColumnValue(e2, j));
			start_level = (int) __min(start_level, ReadColumnValue(e1, j + ctr->point_smooth));
			start_level = (int) __min(start_level, ReadColumnValue(e2, j + ctr->point_smooth));
			start_level = start_level - (start_level % ctr->normal);

			end_level = (int) __max(ReadColumnValue(e1, j), ReadColumnValue(e2, j));
			end_level = (int) __max(end_level, ReadColumnValue(e1, j + ctr->point_smooth));
			end_level = (int) __max(end_level, ReadColumnValue(e2, j + ctr->point_smooth));

			// check cell for each possible contour level 
			// loop using start_level can start at -1...use loop starting at 0
			// to draw 0.0 contour
			for (l = ctr->DrawZeroLine ? 0 : start_level; l <= end_level; l += ctr->normal) {
				// calculate the cell index 
				cell_index = 0;
				if (ReadColumnValue(e2, j) >= l)
					cell_index = 1;
				if (ReadColumnValue(e1, j) >= l)
					cell_index |= 2;
				if (ReadColumnValue(e1, j + ctr->point_smooth) >= l)
					cell_index |= 4;
				if (ReadColumnValue(e2, j + ctr->point_smooth) >= l)
					cell_index |= 8;

				// if cell_index is 0 or 15, no contours at this level 
				if (cell_index == 0 || cell_index == 15)
					continue;

				// calculate the average elevation for the cell,
				// use it to adjust the cell_index 
				ave_elev = ((float) ReadColumnValue(e2, j) + (float) ReadColumnValue(e1, j) + (float) ReadColumnValue(e1, j + ctr->point_smooth) + (float) ReadColumnValue(e2, j + ctr->point_smooth)) / 4.0f;

				if (ave_elev <= (float) l)
					cell_index = cell_index ^ 15;

				// if working on a bold interval, set color to bold color 
				if ((l % ctr->bold) == 0)
					ctr->pDC->SelectObject(ctr->cpBoldPen);

				// set flag to force move to first crossing point 
				flag = 1;

				// step through the side or segment crossings held in the
				// crossing side list 
				for (k = 0; k < em[cell_index] [0]; k ++) {

					// calculate the cell size multiplier...different logic
					// for each side or segment.  Multiplier ranges from 0 to 1 
					switch (el[em[cell_index] [1] + k]) {
						case 0:
							x_mult = 0.0f;
							if (ReadColumnValue(e1, j) == ReadColumnValue(e1, j + ctr->point_smooth))
								y_mult = 0.5f;
							else
								y_mult = ((float) (l - ReadColumnValue(e1, j))) / ((float) (ReadColumnValue(e1, j + ctr->point_smooth) - ReadColumnValue(e1, j)));
							break;
						case 1:
							if (ReadColumnValue(e1, j + ctr->point_smooth) == ReadColumnValue(e2, j + ctr->point_smooth))
								x_mult = 0.5f;
							else
								x_mult = ((float) (l - ReadColumnValue(e1, j + ctr->point_smooth))) / ((float) (ReadColumnValue(e2, j + ctr->point_smooth) - ReadColumnValue(e1, j + ctr->point_smooth)));
							y_mult = 1.0f;
							break;
						case 2:
							x_mult = 1.0f;
							if (ReadColumnValue(e2, j) == ReadColumnValue(e2, j + ctr->point_smooth))
								y_mult = 0.5f;
							else
								y_mult = 1.0f - (((float) (l - ReadColumnValue(e2, j + ctr->point_smooth))) / ((float) (ReadColumnValue(e2, j) - ReadColumnValue(e2, j + ctr->point_smooth))));
							break;
						case 3:
							if (ReadColumnValue(e1, j) == ReadColumnValue(e2, j))
								x_mult = 0.5f;
							else
								x_mult = 1.0f - (((float) (l - ReadColumnValue(e2, j))) / ((float) (ReadColumnValue(e1, j) - ReadColumnValue(e2, j))));
							y_mult = 0.0f;
							break;
						case 4:
							if (ave_elev == (float) ReadColumnValue(e1, j))
								x_mult = 0.25f;
							else
								x_mult = 0.5f * ((float) (l - ReadColumnValue(e1, j))) / (ave_elev - (float) ReadColumnValue(e1, j));
							y_mult = x_mult;
							break;
						case 5:
							if (ave_elev == (float) ReadColumnValue(e1, j + ctr->point_smooth))
								x_mult = 0.25f;
							else
								x_mult = 0.5f * ((float) (l - ReadColumnValue(e1, j + ctr->point_smooth))) / (ave_elev - (float) ReadColumnValue(e1, j + ctr->point_smooth));
							y_mult = 1.0f - x_mult;
							break;
						case 6:
							if (ave_elev == (float) ReadColumnValue(e2, j + ctr->point_smooth))
								x_mult =  0.75f;
							else
								x_mult = 1.0f - (0.5f * ((float) (l - ReadColumnValue(e2, j + ctr->point_smooth))) / (ave_elev - (float) ReadColumnValue(e2, j + ctr->point_smooth)));
							y_mult = x_mult;
							break;
						case 7:
							if (ave_elev == (float) ReadColumnValue(e2, j))
								x_mult = 0.75f;
							else
								x_mult = 1.0f - (0.5f * ((float) (l - ReadColumnValue(e2, j))) / (ave_elev - (float) ReadColumnValue(e2, j)));
							y_mult = 1.0f - x_mult;
							break;
						case 8:
							flag = 1;
							continue;
					}
					// move or draw to the crossing point depending on flag 
					x = column_x + Header.column_spacing * (double) x_mult * (double) ctr->column_smooth;
					y = Header.origin_y + ((double) j * Header.point_spacing) + Header.point_spacing * (double) y_mult * (double) ctr->point_smooth;

					// scale to window coords
					pt.x = wcs.WX(x);
					pt.y = wcs.WY(y);

					if (flag) {
						ctr->pDC->MoveTo(pt);
						flag = 0;
					}
					else {
						ctr->pDC->LineTo(pt);
						if ((l % ctr->bold) == 0)
							ctr->pDC->SetPixel(pt, ctr->bcolor);
						else
							ctr->pDC->SetPixel(pt, ctr->ncolor);
					}
				}
				// if working on a bold interval, reset color to normal 
				if ((l % ctr->bold) == 0)
					ctr->pDC->SelectObject(ctr->cpNormalPen);

				// if working on 0 contour, jump to actual start level 
				if (l == 0) {
					l = start_level - ctr->normal;
					// check for void area markers...(-1) 
					if (ReadColumnValue(e1, j) < 0 || ReadColumnValue(e2, j) < 0 || ReadColumnValue(e1, j + ctr->point_smooth) < 0 || ReadColumnValue(e2, j + ctr->point_smooth) < 0)
						break;
				}
			}
		}
		// check for an [Esc] key press
		if (!ctr->pDC->IsPrinting()) {
			if (PeekMessage(&stopmsg, ctr->pDC->GetWindow()->m_hWnd, WM_KEYUP, WM_KEYUP, PM_REMOVE)) {
				if (stopmsg.wParam == VK_ESCAPE) {
					exit_key = 27;
					break;
				}
			}
		}
	}
	if (!HaveElevations) {
		// free profile arrays and close dtm file 
		free(e1);
		free(e2);
		fclose(modelfile);
	}

	if (exit_key == 27)
		return(TRUE);

	// check to see if there is an uncontoured strip along right side 
	leftover_col = (stop_col - start_col) % ctr->column_smooth;
	leftover_point = (stop_point - start_point) % ctr->point_smooth;

	temp_ctr = *ctr;
	temp_ctr.column_smooth = (short) leftover_col;
	temp_ctr.lower_left.x = Header.origin_x + (stop_col - leftover_col) * Header.column_spacing + (Header.column_spacing * 0.1);

	if (leftover_col) {
		DrawContours(&temp_ctr);
	}

	temp_ctr.column_smooth = ctr->column_smooth;
	temp_ctr.lower_left.x = ctr->lower_left.x;
	temp_ctr.lower_left.y = Header.origin_y + (stop_point - leftover_point) * Header.point_spacing + (Header.point_spacing * 0.1);
	temp_ctr.point_smooth = (short) leftover_point;

	// check to see if there is an uncontoured strip along the top 
	if (leftover_point) {
		DrawContours(&temp_ctr);
	}

	// draw neat line
	if (ctr->DrawNeatLine) {
		ctr->pDC->SelectObject(ctr->cpNormalPen);
		ctr->pDC->SelectStockObject(NULL_BRUSH);
		ctr->pDC->Rectangle(wcs.WX(OriginX()), wcs.WY(OriginY()), wcs.WX(OriginX() + Width()), wcs.WY(OriginY() + Height()));
	}

	return(TRUE);
}
Exemple #8
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 #9
0
/*
 * If cursor not in scrolling region, returns.  Else, deletes n lines
 * at the cursor's position, lines added at bottom margin are blank.
 */
void
DeleteLine(register TScreen *screen, register int n)
{
	register int i;
	register int shift;
	register int bot;
	register int refreshtop;
	register int refreshheight;
	register int scrolltop;
	register int scrollheight;

	if (screen->cur_row < screen->top_marg ||
	 screen->cur_row > screen->bot_marg)
		return;
	if(screen->cursor_state)
		HideCursor();
	screen->do_wrap = 0;
	if (n > (i = screen->bot_marg - screen->cur_row + 1))
		n = i;
    if(screen->jumpscroll) {
	if(screen->scroll_amt >= 0 && screen->cur_row == screen->top_marg) {
		if(screen->refresh_amt + n > screen->max_row + 1)
			FlushScroll(screen);
		screen->scroll_amt += n;
		screen->refresh_amt += n;
	} else if(screen->scroll_amt)
		FlushScroll(screen);
    }
    if(!screen->scroll_amt) {

	shift = -screen->topline;
	bot = screen->max_row - shift;
	scrollheight = i - n;
	refreshheight = n;
	if((refreshtop = screen->bot_marg - refreshheight + 1 + shift) >
	 (i = screen->max_row - refreshheight + 1))
		refreshtop = i;
	if(screen->scrollWidget && !screen->alternate && screen->cur_row == 0) {
		scrolltop = 0;
		if((scrollheight += shift) > i)
			scrollheight = i;
		if((i = screen->savedlines) < screen->savelines) {
			if((i += n) > screen->savelines)
				i = screen->savelines;
			screen->savedlines = i;
			ScrollBarDrawThumb(screen->scrollWidget);
		}
	} else {
		scrolltop = screen->cur_row + shift;
		if((i = screen->bot_marg - bot) > 0) {
			scrollheight -= i;
			if((i = screen->cur_row + n - 1 - bot) >= 0) {
				refreshheight -= i;
			}
		}
	}
	vertical_copy_area(screen, scrolltop+n, scrollheight, n);
	if(refreshheight > 0) {
		ClearCurBackground(screen,
		    (int) refreshtop * FontHeight(screen) + screen->border,
		    (int) OriginX(screen),
		    (unsigned) refreshheight * FontHeight(screen),
		    (unsigned) Width(screen));
	}
    }
	/* adjust screen->buf */
	if(screen->scrollWidget && !screen->alternate && screen->cur_row == 0)
		ScrnDeleteLine(screen, screen->allbuf,
			screen->bot_marg + screen->savelines, 0,
			n, screen->max_col + 1);
	else
		ScrnDeleteLine(screen, screen->visbuf,
			screen->bot_marg, screen->cur_row,
			n, screen->max_col + 1);
}
Exemple #10
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);
}