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

📄 cajfy.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 2 页
字号:
    if (gptr->font_data.algorithmic_attributes & (UL | STRIKE | DOU_UL | OVERLINE ))      {    	    copy_glyph(gptr,&vchar);    	    vchar.char_data.char_width =		  FNT_WIDTH(gptr->char_data.char_font,			    gptr->char_data.char_code)		- get_right_bearing(vchar.char_data.char_code, 				    vchar.char_data.char_font);	    vchar.char_data.char_code = VIR_CHAR_ADD;	    process_vchar(&vchar);    }/* Point to next char again */cur_index++;gptr++;/* Now print all the characters that were entered after the    right most one*/for ( ; cur_index < xl_st.jfy_buf_index  ; cur_index++, gptr++)  {	/* adjust the position of the character */	gptr->ap.xval += cur_char_offset;	/* if the character is not a space */	if ((gptr->char_data.char_code != SP_C) && (gptr->char_data.char_code != VIR_CHAR_SPACE))	{		/* Print the character */		process_char(gptr);	}	else	{	/* This is a space  or a virtual space */		/* If it is beyond the right anchor, ignore it */		if (gptr->ap.xval < xl_st.justify_buf[right_char].ap.xval);		/* It is within bounds, print it */		copy_glyph(gptr,&vchar);		vchar.char_data.char_code = VIR_CHAR_SPACE;		process_vchar(&vchar);		} /*End of characters (if_else space) */}	/*End of for loop *//*	All done, reset things */	enter_jfy();		/* Indicate justify buffer is empty */}/*****  pr_jfy_off()  *************************************************** *									* *	pr_jfy_off - Turn off justification				* ************************************************************************/VOID pr_jfy_off(){#ifdef DUMP    {    oprintf("JUSTIFY OFF \n");        pprint();		    /* Print the parameter list */    }#endif    /*	If Justify mode was on, and a command was received to turn it off.	Empty the justify buffer. */    if (xl_st.justify_mode == JUSTIFY_ON)      {		empty_jfy_buf();	xl_st.justify_mode = JUSTIFY_OFF;    }}/*****  pr_jfy_limits()  ************************************************ *									* *	pr_jfy_limits - Turn on justification with limits		* ************************************************************************/VOID pr_jfy_limits(){#ifdef DUMP    {    oprintf("JUSTIFY LIMITS \n");        pprint();		    /* Print the parameter list */    }#endif    /* Set limits enabled */    xl_st.limits_enabled_flg  = TRUE;    /*	If justify mode was off, and it was just turned on,	call 'enter_jfy()'. */    if (xl_st.justify_mode == JUSTIFY_OFF)  	{    		enter_jfy();		xl_st.justify_mode = JUSTIFY_ON;	}}/*****  pr_jfy()  ******************************************************* *									* *	pr_jfy - Turn on/off justification				* ************************************************************************/VOID pr_jfy(){#ifdef DUMP    {    oprintf("JUSTIFY \n");        pprint();		    /* Print the parameter list */    }#endif    cp_split(ast_jfy_srch);    return;}/****************************************************************************    DEC Private Justify Text****************************************************************************/VOID dec_jfy(){#ifdef DUMP    {    oprintf("DEC JUSTIFY \n");        pprint();		    /* Print the parameter list */    }#endif    cp_split(ast_decjfy_srch);    return;}/****************************************************************************    DEC Private Justify Text No Limits****************************************************************************/VOID dec_jfy_nolimits(){#ifdef DUMP    {    oprintf("DEC JUSTIFY NOLIMITS \n");        pprint();		    /* Print the parameter list */    }#endif    /* Set limits disabled */    xl_st.limits_enabled_flg  = FALSE;    /*	If justify mode was off, and it was just turned on,	call 'enter_jfy()'. */    if (xl_st.justify_mode == JUSTIFY_OFF)  	{    		enter_jfy();		xl_st.justify_mode = JUSTIFY_ON;	}}/*****  justify_buffer()  *********************************************** *									* * Justify the line in the justify buffer by:				* *  - Scanning off leading and trailing spaces				* *  - Count the number of spaces between the first and last characters	* *	that cause the effective ahp to be increased			* *  - Calculate the space_adj necessary to expand or contract the line	* *	to have the line justified between the left anchor and right	* *	margin								* *  - If limits are enabled, and the effective size of a space char	* *	will be too small or too big, set space_adj = 0.		* ************************************************************************/VOID	justify_buffer(){	GLYPH	*gptr;	LONG	right_maxahp, max_ahp;	WORD	i, num_spaces;	LONG	print_area, text_area, amount_to_spread, size_of_space;	LONG    left_bearing;	/* Hold centerlines a character for purpose */	LONG    right_anchor;	/*   for purpose of justification */	BOUND	space_lim;	/* With limits enabled, hold the minimum and */				/*   maximum allowable width for a space char */	/* Set default for space character adjustment factor */	space_adj = 0;    	/* If justify buffer is empty, don't waste time trying to justify! */    	if (xl_st.jfy_buf_index  == 0)		return;	/* Remove trailing spaces in the justify buffer */	gptr = &xl_st.justify_buf[xl_st.jfy_buf_index -1];	while (0 < xl_st.jfy_buf_index )  	{		if (gptr->char_data.char_code != SP_C)	break;		gptr--;		xl_st.jfy_buf_index --;	}	/* Scan off the leading spaces in the justify buffer */	gptr = &xl_st.justify_buf[0];	left_char = 0;	while (left_char < xl_st.jfy_buf_index )  	{		if (gptr->char_data.char_code != SP_C)	break;		gptr++;		left_char++;	}	/* Return if no non-spaces were found */	if (left_char == xl_st.jfy_buf_index )  	return;	/* Fetch the left bearing of the character that forms the left anchor,	   and calculate a left_anchor */	left_bearing = get_left_bearing(gptr->char_data.char_code,					gptr->char_data.char_font);	left_anchor = gptr->ap.xval;	/* Continue scanning the justify buffer and record as right_char the	   character that logs the highest ahp value. */	i = right_char = left_char;	right_maxahp = left_anchor;	while (i < xl_st.jfy_buf_index )  	{		if (	(gptr->ap.xval > right_maxahp)		     &&	(gptr->char_data.char_code != SP_C)  		   )		{			right_maxahp = gptr->ap.xval;			right_char = i;		}		gptr++;  i++;	}	/* Fetch the right bearing of the character that logged the highest	   ahp and add to its ahp */	gptr = &xl_st.justify_buf[right_char];		/* Was using modified width of character (wid) should 	** use "true" width	** right_maxahp = gptr->ap.xval + 	**		  gptr->char_data.char_width -	**		  get_right_bearing(gptr->char_data.char_code,	**				    gptr->char_data.char_font);		*/	/* Fetch the real width of the rightmost character, in 	**   case, we are using spacing 	*/	right_maxahp =		   gptr->ap.xval		 + FNT_WIDTH(gptr->char_data.char_font,			     gptr->char_data.char_code)		 - get_right_bearing(gptr->char_data.char_code,				     gptr->char_data.char_font);	/* Now lets count the number of spaces between the character on the 	   left anchor point and the character that logged the highest ahp to	   the right (only the spaces that cause the effective ahp to be	   incremented count provided they are not beyond the 	   right most printable) */	i = left_char;	gptr = &xl_st.justify_buf[left_char];	max_ahp = gptr->ap.xval;	num_spaces = 0;	while (i <= right_char)  	{		if (gptr->ap.xval > max_ahp)  		{			if (gptr->char_data.char_code != SP_C) max_ahp = gptr->ap.xval;			else			{	if (gptr->ap.xval <= xl_st.justify_buf[right_char]								    .ap.xval)				{					max_ahp = gptr->ap.xval;					num_spaces++;				}			}		}		gptr++;  i++;	}	/* If num_spaces =0, return with space_adj = 0 so we don't get	   any divide errors in the code that follows */	if (num_spaces == 0)		return;	/* Line end pos is the right anchor point for justification.	   Calculate print area as right anchor - left anchor */	right_anchor = xl_st.h_fmt_bound.max;	print_area = right_anchor - left_anchor;	/* text area (including SP's) = right max ahp - (left anchor + left bearing of first char) */	text_area = right_maxahp - (left_anchor + left_bearing);	/* amount to spread = print area - text area */	amount_to_spread = print_area - text_area;	/* Calculate the amount to add to each final space that is output */	/* Note, if the adjustment is positive, the divide will round down which	   ok, but id it is negative, it will be rounded up, which is bad.	   So a little magic is used to garantee a rounding down        */	if (amount_to_spread >= 0)	{	    space_adj = amount_to_spread / (LONG) num_spaces;	}	else	{	    space_adj = (amount_to_spread - (num_spaces -1) )/ (LONG) num_spaces;	}	/* Get width of a space character of the font type found in the	first character in the justify buffer */	size_of_space = get_width((WORD)SP_C, xl_st.justify_buf[0]						    .char_data.char_font);	/* If the adjustement would make the space < 0, limit it to zero */	if ( ( space_adj + size_of_space) < 0 )	{		space_adj = (-size_of_space);	}	/* If limits are enabled, then if the width of a space character with	   the newly-calculated adjustment factor is less than the minimum	   space width, or greater than the maximum space width allowed,	   then set the space adjustment factor = 0.  */	if (xl_st.limits_enabled_flg )  	{		/* Get limits */		get_font_limits((WORD)SP_C, xl_st.justify_buf[0]					    .char_data.char_font,&space_lim);		/* Check */		if ( (size_of_space + space_adj) > space_lim.max)		{			space_adj = 0;		}		if ( (size_of_space + space_adj) < space_lim.min)		{			space_adj = space_lim.min - size_of_space;		}	}} /* End justify_buffer *//*****  add_to_jfy_buf()  *********************************************** *									* *	add_to_jfy_buf(glyph) - Add the character to the justify	* *	buffer.  Return to the caller the width of the character.	* ************************************************************************/LONG	add_to_jfy_buf(cglyph)GLYPH	*cglyph;{    	if (xl_st.jfy_buf_index  >= JBUF_SIZE) empty_jfy_buf();	/* Capture the current translator state and save it with the character	   in the justify buffer */    	copy_glyph(cglyph,&xl_st.justify_buf[xl_st.jfy_buf_index ++]);	return(cglyph->char_data.char_width);		/* Return the width of the character */}

⌨️ 快捷键说明

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