⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.c

📁 源码,标准c++用力
💻 C
📖 第 1 页 / 共 3 页
字号:
		    (unsigned) refreshheight * FontHeight(screen),		    FALSE);    }	/* adjust screen->buf */	ScrnInsertLine(screen->buf, screen->bot_marg, screen->cur_row, n,			screen->max_col + 1);}/* * If cursor not in scrolling region, returns.  Else, deletes n lines * at the cursor's position, lines added at bottom margin are blank. */DeleteLine(screen, n)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)		XClearArea (		    screen->display,		    TextWindow(screen),		    (int) screen->border + screen->scrollbar,		    (int) refreshtop * FontHeight(screen) + screen->border,		    (unsigned) Width(screen),		    (unsigned) refreshheight * FontHeight(screen),		    FALSE);    }	/* adjust screen->buf */	if(screen->scrollWidget && !screen->alternate && screen->cur_row == 0)		ScrnDeleteLine(screen->allbuf, screen->bot_marg +		 screen->savelines, 0, n, screen->max_col + 1);	else		ScrnDeleteLine(screen->buf, screen->bot_marg, screen->cur_row,		 n, screen->max_col + 1);}/* * Insert n blanks at the cursor's position, no wraparound */InsertChar (screen, n)    register TScreen *screen;    register int n;{        register int cx, cy;		GC currentGC;		register unsigned flags = term->flags;	if(screen->cursor_state)		HideCursor();	screen->do_wrap = 0;	if(screen->cur_row - screen->topline <= screen->max_row) {	    if(!AddToRefresh(screen)) {		if(screen->scroll_amt)			FlushScroll(screen);		/*		 * prevent InsertChar from shifting the end of a line over		 * if it is being appended to		 */		if (non_blank_line (screen->buf, screen->cur_row, 				    screen->cur_col, screen->max_col + 1))		    horizontal_copy_area(screen, screen->cur_col,					 screen->max_col+1 - (screen->cur_col+n),					 n);			cx = CursorX (screen, screen->cur_col);		cy = CursorY (screen, screen->cur_row);		if (flags & INVERSE)		{	currentGC = screen->normalGC;			if (flags & FG_COLOR)				XSetForeground(screen->display, currentGC, 								screen->colors[term->cur_foreground]);		} else		{	currentGC = screen->reverseGC;			if (flags & BG_COLOR)				XSetForeground(screen->display, currentGC,								screen->colors[term->cur_background]);		}		XFillRectangle(		    screen->display,		    TextWindow(screen), 		    currentGC,		    cx, cy,		    (unsigned) n * FontWidth(screen), (unsigned) FontHeight(screen));	    }	}	/* adjust screen->buf */	ScrnInsertChar(screen->buf, screen->cur_row, screen->cur_col, n,			screen->max_col + 1);}/* * Deletes n chars at the cursor's position, no wraparound. */DeleteChar (screen, n)    register TScreen *screen;    register int	n;{	register int width;	if(screen->cursor_state)		HideCursor();	screen->do_wrap = 0;	if (n > (width = screen->max_col + 1 - screen->cur_col))	  	n = width;			if(screen->cur_row - screen->topline <= screen->max_row) {	    if(!AddToRefresh(screen)) {		if(screen->scroll_amt)			FlushScroll(screen);			horizontal_copy_area(screen, screen->cur_col+n,				     screen->max_col+1 - (screen->cur_col+n),				     -n);			XFillRectangle		    (screen->display, TextWindow(screen),		     screen->reverseGC,		     screen->border + screen->scrollbar		       + Width(screen) - n*FontWidth(screen),		     CursorY (screen, screen->cur_row), n * FontWidth(screen),		     FontHeight(screen));	    }	}	/* adjust screen->buf */	ScrnDeleteChar (screen->buf, screen->cur_row, screen->cur_col, n,			screen->max_col + 1);}/* * Clear from cursor position to beginning of display, inclusive. */ClearAbove (screen)register TScreen *screen;{	register 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)			XClearArea(screen->display, TextWindow(screen),			 screen->border + screen->scrollbar, top *			 FontHeight(screen) + screen->border,			 Width(screen), height * FontHeight(screen), FALSE);		if(screen->cur_row - screen->topline <= screen->max_row)			ClearLeft(screen);	}	ClearBufRows(screen, 0, screen->cur_row - 1);}/* * Clear from cursor position to end of display, inclusive. */ClearBelow (screen)register TScreen *screen;{	register top;	ClearRight(screen);	if((top = screen->cur_row - screen->topline) <= screen->max_row) {		if(screen->scroll_amt)			FlushScroll(screen);		if(++top <= screen->max_row)			XClearArea(screen->display, TextWindow(screen),			 screen->border + screen->scrollbar, top *			 FontHeight(screen) + screen->border,			 Width(screen), (screen->max_row - top + 1) *			 FontHeight(screen), FALSE);	}	ClearBufRows(screen, screen->cur_row + 1, screen->max_row);}/*  * Clear last part of cursor's line, inclusive. */ClearRight (screen)register TScreen *screen;{#ifdef DEBUGGING	fprintf(stderr, "entering ClearRight");#endif	if(screen->cursor_state)		HideCursor();	screen->do_wrap = 0;	if(screen->cur_row - screen->topline <= screen->max_row) {	    if(!AddToRefresh(screen)) {	if(screen->scroll_amt)		FlushScroll(screen);		XFillRectangle(screen->display, TextWindow(screen),		  screen->reverseGC,		 CursorX(screen, screen->cur_col),		 CursorY(screen, screen->cur_row),		 Width(screen) - screen->cur_col * FontWidth(screen),		 FontHeight(screen));	    }	}#ifdef DEBUGGING	fprintf(stderr, "Made it to the bzero's.\n");#endif	bzero(screen->buf [4 * screen->cur_row] + screen->cur_col,	       (screen->max_col - screen->cur_col + 1));	bzero(screen->buf [4 * screen->cur_row + 1] + screen->cur_col,	       (screen->max_col - screen->cur_col + 1));	bzero(screen->buf [4 * screen->cur_row + 2] + screen->cur_col,			(screen->max_col - screen->cur_col + 1));	bzero(screen->buf [4 * screen->cur_row + 3] + screen->cur_col,			(screen->max_col - screen->cur_col + 1));	/* with the right part cleared, we can't be wrapping */	screen->buf [4 * screen->cur_row + 1] [0] &= ~LINEWRAPPED;#ifdef DEBUGGING	fprintf(stderr, "Leaving clearright");#endif}/* * Clear first part of cursor's line, inclusive. */ClearLeft (screen)    register TScreen *screen;{        int i;	Char *cp;	if(screen->cursor_state)		HideCursor();	screen->do_wrap = 0;	if(screen->cur_row - screen->topline <= screen->max_row) {	    if(!AddToRefresh(screen)) {		if(screen->scroll_amt)			FlushScroll(screen);		XFillRectangle (screen->display, TextWindow(screen),		     screen->reverseGC,		     screen->border + screen->scrollbar,		      CursorY (screen, screen->cur_row),		     (screen->cur_col + 1) * FontWidth(screen),		     FontHeight(screen));	    }	}		for ( i=0, cp=screen->buf[4 * screen->cur_row];	      i < screen->cur_col + 1;	      i++, cp++)	    *cp = ' ';	for ( i=0, cp=screen->buf[4 * screen->cur_row + 1];	      i < screen->cur_col + 1;	      i++, cp++)	    *cp = CHARDRAWN;	bzero (screen->buf [4 * screen->cur_row + 2], (screen->cur_col + 1));	bzero (screen->buf [4 * screen->cur_row + 3], (screen->cur_col + 1));}/*  * Erase the cursor's line. */ClearLine(screen)register TScreen *screen;{	if(screen->cursor_state)		HideCursor();	screen->do_wrap = 0;	if(screen->cur_row - screen->topline <= screen->max_row) {	    if(!AddToRefresh(screen)) {		if(screen->scroll_amt)			FlushScroll(screen);		XFillRectangle (screen->display, TextWindow(screen), 		     screen->reverseGC,		     screen->border + screen->scrollbar,		      CursorY (screen, screen->cur_row),		     Width(screen), FontHeight(screen));	    }	}	bzero (screen->buf [4 * screen->cur_row], (screen->max_col + 1));	bzero (screen->buf [4 * screen->cur_row + 1], (screen->max_col + 1));	bzero (screen->buf [4 * screen->cur_row + 2], (screen->max_col + 1));	bzero (screen->buf [4 * screen->cur_row + 3], (screen->max_col + 1));}ClearScreen(screen)register TScreen *screen;{	register int top;	if(screen->cursor_state)		HideCursor();	screen->do_wrap = 0;	if((top = -screen->topline) <= screen->max_row) {		if(screen->scroll_amt)			FlushScroll(screen);		if(top == 0)			XClearWindow(screen->display, TextWindow(screen));		else			XClearArea(screen->display, TextWindow(screen),			 screen->border + screen->scrollbar, 			 top * FontHeight(screen) + screen->border,			 	 Width(screen), (screen->max_row - top + 1) *			 FontHeight(screen), FALSE);	}	ClearBufRows (screen, 0, screen->max_row);}CopyWait(screen)register TScreen *screen;{	XEvent reply;	XEvent *rep = &reply;	while (1) {		XWindowEvent (screen->display, VWindow(screen), 		  ExposureMask, &reply);		switch (reply.type) {		case Expose:			HandleExposure (screen, &reply);			break;		case NoExpose:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -