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

📄 eebuff.c

📁 操作系统源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*	Divide the current window in half, put the current buffer in the *	other window, and go to the new window. */f_2winds(){	register int h, t;	register struct window *w;	if (oth_win)	  {#if !(IMAGEN)		ding("Already 2 windows");#endif /*-IMAGEN*/		return;	  }	w = cur_win;	d_fixcur();			/* Stabilize current window */	h = (w->w_ht) / 2;	t = w->w_pos + h;		/* Pos of dividing window */	sep_win = make_win(t, 1, lines_buf);					/* assume using dashes to separate */	oth_win = make_win(t + 1, w->w_ht - (h + 1), cur_buf);					/* Other window has balance */#if FX_SOWIND	oth_win->w_flags |= cur_win->w_flags&W_STANDOUT;	sep_win->w_flags |= mode_win->w_flags&W_STANDOUT;#endif#if FX_2MODEWINDS	chk2modws();			/* Update 2-mode-wind status */#endif	w->w_ht = h;			/* Decrease current window to half */	/* Minimize redisplay by moving each window's dot into	 * a currently displayed area */	if(cur_dot < (oth_win->w_topldot = scr[t+1]->sl_boff))		oth_win->w_dot = oth_win->w_topldot;	/* Adj bottom win */	else					/* Adjust top window */	  {	oth_win->w_dot = cur_dot;	/* Bottom keeps dot */		cur_dot = scr[t-1]->sl_boff;	/* but top needs new one. */	  }	f_othwind();			/* switch to other window */	redp(RD_WINDS);			/* Update all windows */}/* EFUN: "One Window" *//*	Revert to using only one window; use the current buffer (unlike *	EMACS which always selects the top window's buffer) *	Ensures that current window's vars are correctly set for *	new dimensions (w_pos, w_ht, plus w_topldot to minimize redisplay), *	then kills unneeded windows. */f_1wind(){	register struct window *w;	if (oth_win == 0)	  {#if (!IMAGEN)		ding("Only 1 window");#endif /*-IMAGEN*/		return;	  }	w = cur_win;	if(w->w_pos)		/* If not top window */	  {	d_fixcur();		/* Ensure screen-line data correct */		e_go(w->w_topldot);	/* Beginning from top of window, */		d_fgoloff(-w->w_pos);	/* Move back enough lines */		w->w_topldot = e_dot();	/* To set new start of window */		e_gocur();		/* Then move back to orig place */		w->w_pos = 0;	  }	w->w_ht += oth_win -> w_ht + 1;	kill_win (oth_win);	kill_win (sep_win);	oth_win = sep_win = 0;#if FX_2MODEWINDS	chk2modws();	/* Update notion of whether have 2 mode winds */#endif	redp(RD_FIXWIN|RD_WINDS|RD_MODE); /* New topldot for this window,					 * and check all remaining windows */}/* EFUN: "Other Window" *//*	Move to the "other" user window. */f_othwind (){	if (oth_win == 0)	  {#if !(IMAGEN)		ding("Only 1 window");#endif /*-IMAGEN*/		return;	  }	chg_win(oth_win);	oth_win = user_win;	user_win = cur_win;	redp(RD_MODE);}/* EFUN: "Grow Window" *//*	Grow the current window - while in two window mode, *	increase the size of the current window by the arg *	and decrease the other accordingly */f_growind(){	register struct window *cw, *ow;	register int e;	if ((ow = oth_win) == 0)	  {#if !(IMAGEN)		ding("Only 1 window");#endif /*-IMAGEN*/		return;	  }	e = exp;	if((cw = cur_win)->w_pos != 0)	/* If current window is on bottom */	  {	cw = ow;		/* Then fake code to think it's top */		ow = cur_win;		e = -e;	  }	if(  cw->w_ht + e < 1	  || ow->w_ht + e < 1)	  {	ding("Too much");		return;	  }	cw -> w_ht += e;	ow -> w_pos += e;	ow -> w_ht -= e;	sep_win -> w_pos += e;	redp(RD_WINDS | RD_MODE);		/* Update all windows */}#if FX_SHRINKWIND/* EFUN: "Shrink Window" (not EMACS) - from IMAGEN config */f_shrinkwind(){	if (! oth_win)		return;	f_othwind();	f_growind();	f_othwind();}#endif /*FX_SHRINKWIND*/#if FX_DELWIND/* EFUN: "Delete Window" (not EMACS) - from IMAGEN config */f_delwind(){	if(!oth_win)		return;	f_othwind();	f_1wind();}#endif /*FX_DELWIND*/#if FX_SOWIND/* EFUN: "Standout Window" (not EMACS) *//*	Toggles the display standout mode for the current window.**	With argument of 4, toggles the standout mode for the non-buffer**	parts of the screen, such as the ELLE mode line.** (This corresponds to FS INVMOD$ in EMACS)**	With argument of 0, turns standout mode off for all windows.*//* It suffices to set the window flag bit and force a RD_WINRES for that * window; the redisplay code will do the rest.*/static void tgso_wind();f_sowind(){	register struct window *w;	switch(exp)	  {	default:		/* Toggle current window */			tgso_wind(cur_win);			break;		case 4:			/* Toggle mode & separator windows */			tgso_wind(mode_win);			tgso_wind(sep_win);	/* This may not exist */			break;		case 0:			/* Turn off standout for all winds */			for(w = win_head; w; w = w->w_next)				if(w->w_flags&W_STANDOUT)					tgso_wind(w);	  }#if FX_2MODEWINDS	chk2modws();	/* Update notion of whether have 2 mode winds */#endif}static voidtgso_wind(w)		/* Toggle standout mode for given window */register struct window *w;{	if (w == 0) return;		/* For case of no sep_win */	if (w->w_flags & W_STANDOUT)		w->w_flags &= ~W_STANDOUT;	else w->w_flags |= W_STANDOUT;	w->w_redp |= RD_WINRES;		/* Re-do this particular window */	redp(RD_CHKALL);		/* Check all windows for changes */}#endif /*FX_SOWIND*/#if FX_2MODEWINDS/* EFUN: "Two Mode Windows" (not EMACS) *//*	With arg, sets ev_2modws to that value (0, 1, or 2).**	No arg, toggles current setting between 0 and 2.*/f_2modewinds(){	ev_2modws = exp_p ? exp : (ev_2modws ? 0 : 2);	chk2modws();}/* CHK2MODWS - Called after anything changes which might affect**	whether 2 mode windows are in effect or not.  Fixes up**	sep_win to either be or not be a mode window.*/chk2modws(){	register struct window *w;	static struct buffer *sep_buf = 0;	if(!(w = sep_win))	  {	sepmode_p = 0;		/* Don't have 2 windows at all */		return;	  }	sepmode_p = (ev_2modws == 1)			? (mode_win->w_flags&W_STANDOUT)			: ev_2modws;	if(sepmode_p)		/* Turn 2-mode-winds on? */	  {		if(!sep_buf)			sep_buf = make_buf(" **SEPMODE**");		w->w_buf = sep_buf;		w->w_flags |= W_MODE;	  }	else			/* Turn 2-mode-winds off */	  {	w->w_buf = lines_buf;		w->w_flags &= ~W_MODE;		redp(RD_CHKALL);	/* No longer a mode win, so must */					/* check all to ensure it's updated */	  }	w->w_redp |= RD_WINRES;	redp(RD_MODE);}#endif /*FX_2MODEWINDS*/init_win (){	win_head = 0;	oth_win = 0;	user_win = make_win(0, scr_ht - (ECHOLINES+1), cur_buf); /* Main */	mode_win = make_win(scr_ht - (ECHOLINES+1), 1, make_buf(" **MODE**"));	ask_win  = make_win(scr_ht - ECHOLINES,     1, make_buf(" **ASK**"));#if FX_SOWIND	if(ev_modwso)		mode_win->w_flags |= W_STANDOUT;#endif	cur_win = user_win;}chg_win(newwin)		       /* change current window to newwin */struct window *newwin;{	cur_win->w_dot = cur_dot;	/* Save window's current dot */	cur_win->w_redp |= rd_type&RDS_WINFLGS;	/* and its redisplay flags */	cur_win = newwin;		/* OK, switch to new current window */	cur_buf = newwin->w_buf;	/* Set new buffer from win */	e_gosetcur(newwin->w_dot);	/* Set new cur_dot from win too */			/* Note done this way to canonicalize the location			** (may be past new EOB) and ensure SB buffer			** internals agree with cur_dot.			*/	rd_type &= ~RDS_WINFLGS;	/* Remove old per-window flags */	redp(RD_WINRES|RD_MODE);	/* Maybe caller shd handle? */			/* Note WINRES must be set in case we are pointing			 * to a buffer that was modified while we were in			 * the other window!			 */}struct window *make_win (pos, ht, buf)int pos, ht;struct buffer *buf;{	register struct window *w;	register struct buffer *b;	b = buf;	w = (struct window *) memalloc(sizeof (struct window));	w->w_flags = 0;	w->w_pos = pos;	w->w_ht = ht;	w->w_buf = b;	w->w_dot = b->b_dot;	/* Set dot from buffer value */	w->w_topldot = 0;	/* Set top of window to beg of buffer */	w->w_pct = 200;		/* Assume "ALL" */	w->w_bmod = 0;	w->w_emod = 0;	w->w_oldz = 0;	w->w_redp = RD_WINRES;	/* Window will need complete update */	w->w_next = win_head;	/* Done, now link it in */	win_head = w;	return (w);}kill_win (win)struct window *win;{	register struct window *w, *w1, *kw;	kw = win;	w1 = 0;	for (w = win_head; w && w != kw; w = w -> w_next)		w1 = w;	if (w == 0)	  {	ring_bell();		errbarf("No such window");	/* Internal error */		return;	  }	if (w1 == 0)		win_head = w -> w_next;	else		w1 -> w_next = w -> w_next;	kw->w_buf->b_dot = (kw == cur_win) ? cur_dot : kw->w_dot;	chkfree (kw);#if IMAGEN		/* Not needed? */	redp (RD_WINRES|RD_WINDS|RD_REDO);#endif /*IMAGEN*/}/* * "Show-window" routines, used to set up, step through, and close a * temporary "show" window. * MK_SHOWIN(bufp) * UP_SHOWIN() * KL_SHOWIN() *//* MK_SHOWIN(bufp) - Temporarily display a buffer */mk_showin(b)struct buffer *b;{	register struct window *w;	register int i;	int moreflg, intflg;		/* Interrupt flag */	struct window *savwin;	/* First must set up special window... */	savwin = cur_win;	chg_win(w = make_win(0, scr_ht-(ECHOLINES+3), b)); redo:	d_fixcur();		/* Fix up screen image of current window */	/* Find how many lines actually used, and reduce size to that */	i = w->w_ht;	while(--i >= 0)	  {		if(scr[i]->sl_boff != w->w_oldz) break;	  }	if(++i <= 0)		goto skipit;	/* Punt the whole thing */	if(!(moreflg = (i >= w->w_ht)))		w->w_ht = i;	/* Reduce size of window */	intflg = upd_wind(w);	/* Update the window! */	if(!intflg)		/* Unless input waiting, add prompt. */	  {		yellat( moreflg ?	"--MORE-- (type Space for more, or type any command to flush)" :	"------------------------------------------------ (Hit space to continue)--",			w->w_ht);			  }	tbufls();		/* Ensure all output forced out */	i = cmd_read();		/* then wait for user to input a char */	if(i == SP)	  {	if(moreflg)		  {	yellat("", w->w_ht);			d_screen(1);			w->w_redp |= RD_WINRES;			goto redo;		  }	  }#if !(IMAGEN)		/* IMAGEN - always ignore what was typed */	else unrchf = i;#endif /*-IMAGEN*/skipit:	chg_win(savwin);	kill_win(w);	redp(RD_WINDS);		/* Update all remaining windows */}/* Mode Line generation */struct window *make_mode(bw)register struct window *bw;	/* Base window we are reporting status of */{	register struct buffer *b;	/* Buffer of this window */	struct window *mw, *savew;	/* Save current window */	struct buffer *saveb;	/* and current buffer (in case different) */	char temp[20];	saveb = cur_buf;	/* Save values prior to context switch */	savew = cur_win;	b = bw->w_buf;		/* Get buffer for that window */#if FX_2MODEWINDS	if((mw = sep_win) && (mw->w_flags&W_MODE) &&	    (bw->w_pos == 0))		/* Base window is top window? */	  {				/* Use sep_win as mode wind */	  }	else#endif		mw = mode_win;		/* Default is normal mode window */	chg_win(mw);			/* Go to mode line window */	e_gobob();			/* go to beginning */	e_reset();			/* Flush buffer */#if IMAGEN	e_sputz(" ");	e_sputz(b->b_name);	if (b -> b_flags & B_MODIFIED)		e_sputz("*");	e_sputz(" (");	if (b->b_flags & B_QUERYREP)		e_sputz("[Query Replace] ");	if (b->b_flags & B_CMODE)		e_sputz("C");	else if (b->b_flags & B_TEXTMODE)		e_sputz("Text");	else		e_sputz("Fundamental");	e_sputz(")  ");	if (b->b_fn)		e_sputz(b->b_fn);	e_sputz("      ");#else	e_sputz(ev_verstr);		/* Editor name/version */	e_sputz(" (");	e_sputz(cur_mode->mjm_name);	/* insert major mode name */#if FX_FILLMODE	if(fill_mode) e_sputz(" Fill");#endif /*FX_FILLMODE*/#if FX_SKMAC	if(kdef_mode) e_sputz(" MacroDef");#endif /*FX_SKMAC*/	e_sputz(") ");	e_sputz(b->b_name);		/* buffer name */	e_sputz(": ");	if (b->b_fn)		e_sputz(b->b_fn);       /* file name */	if (b->b_flags & B_MODIFIED)		e_sputz(" *");	else	e_sputz("  ");#endif /*-IMAGEN*/	if(bw->w_pct < 200)		/* Not ALL? */	  {	e_sputz(" --");		switch(bw->w_pct)		  {	case -1:				e_sputz("TOP");				break;			case 150:				e_sputz("BOT");				break;			default:				dottoa(&temp[0],(chroff)bw->w_pct);				e_sputz(&temp[0]);				e_putc('%');		  }		e_sputz("--");	  }#if FX_SOWIND	if(mw->w_flags&W_STANDOUT)		e_insn(SP, (int)(scr_wd0 - e_blen()));	/* Stuff out with spaces */#endif	redp(RD_WINRES);	chg_win(savew);		/* Restore context */	chg_buf(saveb);	return(mw);		/* Return mode window */}buf_mod(){	register struct buffer *b;	b = cur_buf;	if((b->b_flags & B_MODIFIED) == 0)	  {	b->b_flags |= B_MODIFIED;		redp(RD_MODE);	  }}/* BUF_TMOD - called when text modified in buffer, to set all *	the appropriate indicators so that redisplay works right. *	Changed text is everything from CUR_DOT to the given offset *	from same.  If stuff was deleted, offset should be 0. * BUF_TMAT - similar but argument is location of other end of range, *	when caller knows that and wants life easy. */buf_tmat(dot)chroff dot;{	buf_tmod(dot - cur_dot);	/* Convert to offset */}buf_tmod(offset)chroff offset;{	register struct window *w;	chroff a, b, tmp;	w = cur_win;	a = cur_dot;	b = a + offset;	if(a > b)	/* Get into right order */	  {	tmp = a;		a = b;		b = tmp;	  }	b = e_blen() - b;	/* Make upper bound relative to EOB */	if(w->w_bmod < 0)	/* Have range vars been set yet? */	  {	w->w_bmod = a;	/* Nope, so can just set 'em now. */		w->w_emod = b;	  }	else	  {	if(a < w->w_bmod)			w->w_bmod = a;		if(b < w->w_emod)			w->w_emod = b;	  }	buf_mod();		/* Maybe later just insert here? */	redp(RD_TMOD);}

⌨️ 快捷键说明

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