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

📄 cajfy.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifndef lintstatic char SccsId[] = "  @(#)cajfy.c	4.1   LPS_ULT_TRN   7/2/90";#endif/* file: cajfy.c * *	COPYRIGHT  (c)  DIGITAL  EQUIPMENT CORPORATION 1985, *	1986, 1987, 1988, 1989 ALL RIGHTS RESERVED. * *	THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE *	USED AND COPIED ONLY IN ACCORDANCE  WITH THE TERMS OF *	SUCH  LICENSE  AND  WITH  THE  INCLUSION OF THE ABOVE *	COPYRIGHT  NOTICE.  THIS SOFTWARE OR ANY OTHER COPIES *	THEREOF   MAY  NOT  BE  PROVIDED  OR  OTHERWISE  MADE *	AVAILABLE  TO  ANY  OTHER  PERSON.  NO  TITLE  TO AND *	OWNERSHIP  OF  THE  SOFTWARE  IS  HEREBY TRANSFERRED. * *	THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE *	WITHOUT  NOTICE  AND SHOULD  NOT BE  CONSTRUED  AS A *	COMMITMENT  BY  DIGITAL EQUIPMENT CORPORATION. * *	DIGITAL  ASSUMES  NO RESPONSIBILITY  FOR THE  USE  OR *	RELIABILITY  OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT *	SUPPLIED BY DIGITAL. * *//* *----------------------------------------------------------- * *   begin edit_history * *   001   28-JAN-1988 13:12  mhw *	    Initial entry for common code * *   002   15-FEB-1988 11:51  bf *	    Merged real and debug code. * *   29-MAR-1988 17:10  mhs *   Add support for JFY split tables, plus stubs for new  *   routines for limits/nolimits/jfyoff. * *  22-JUL-1988 10:30 mhw *	Call process_vchar, not process_char for space and blob * *  31-AUG-1988 09:02 mhw *	Space in justify should use vir_char_add, not vir_char_space * *  29-NOV-1988 13:32 mhw *	vir_char_space does not = 20h anymore, so it must be tested for *	in the justify routine, else process_char would be called * *  18-DEC-1988 15:19 ejs *		Major changes to data structutes.  GLYPH has been modified *		to allow struct copies more easily.  The PS output is not *		changed (barring bugs of course). * *   end edit_history * *----------------------------------------------------------- *//* *----------------------------------------------------------- * *   begin description * *   Filename:  cajfy.c * *	Combination of Dump Utility version and real code  * *    The module contains * *   dec_jfy() * pr_jfy ()		- Handle ANSI justify command * enter_jfy()		- Init for a new line to be justified * add_to_jfy_buf()	- Add another char to the justify buffer * empty_jfy_buf()	- Dispose of contents of justify buffer * justify_buffer()	- Calculate a space char adjustment factor * *   end description * *----------------------------------------------------------- *//* Translator edit history for this file * * file:	xlc_jfy.c - Translator justification routines * created:	gh	 12-MAR-1986 12:10:41 * edit:	gh   	 24-MAR-1986 10:49:45 variable names update *		gh	 26-MAR-1986 14:43:16 put max on add_to_jfy_buf *		gh	 8-APR-1986 15:49:56 Changing justify_buffer to empty *			  w/o justification the jfy buf when it overflows, & *			  when justify was on then JFY-off sequence received. *			  Bumped justify buffer size up to 512. *		gh	 7-MAY-1986 17:21:01 Updated call to get_width() *		gh	 3-JUN-1986 10:33:15 There were still three places where *			  'clib' routines were being called with 'glyph->font' *			  rather than 'glyph->font.ps_font_number'. - fixed *		gh	 16-JUN-1986 13:41:18 Changing pr_jfy() to allow *			  selecting jfty_with_limits once jfy_wo_limits already *			  in effect and visa-versa. *		gh	 27-JUN-1986 13:52:35 Adding processing of virtual chars *			 in empty_jfy_buf() *		gh	 14-JUL-1986 15:14:39 Since the right bearing can be *			 beyond the next chaacter's starting ahp, empty_jfy_buf *			 must therefore output a VIR_ADD char instead of a *			 VIR_ERASE on the first and last chars of a justified *			 line.  Adding this code. *		gh	 21-JUL-1986 14:23:42 Fixed how right bearing was used *			 in justification calculations. * *		araj	 1-OCT-1986 14:48:17 Trying to fix the  *			position used for the erasure of the attributes  *			that extend past the left and right  *			anchors (remember that the characters  *			are aligned with the anchors, not their charbox, but that the  *			attributes work on the full box, causing a few dashes outside  *			the anchors). The problem is that the  *			position of the erase commands is not  *			computed properly In addition, trailing  *			blanks are printed when they should not. *			As a irst step, just moving stuff around  *			so I can read it. * *		araj	 3-OCT-1986 12:14:34 Note that in the  *			mean time, Nick incorporated two of these *			fixes in a temporary version, to drop trailing spaces *			and fix ahp = avp + temp * *		araj	 20-OCT-1986 08:53:27  *			Inverted with_limits/Without_limits, as  *			these were the opposite of the spec. * *			Added a test to ensure that even without  *			limits, the width of space remains > 0 * *			Improved teh parameter tests, to ensure  *			that only valid parameters are  *			processed, up to now, any sequence *			would toggle the state, unless the  *			new parameter was equal to the previous  *			one that would be fine if an other test  *			was made to allow only for valid  *			parameters. * *			Added a reprint of the first and last  *			character to suppress dents when erasing *			attributes that exceed the border. * *		 21-OCT-1986 09:25:10 araj *			Modified code to use limits when  *			limits are exceeded, rather than 0 * *		 23-OCT-1986 08:47:02 araj *			Modified code to use o when limits *			are exceeded rather than limits *			A previous QAR caused the above *			change, because they wanted us to use  *			lower limit when the lower limit was  *			exceeded, the wording caused the *			limits to be used for both Min and  *			max. They want us to use 0 if max is  *			exceeeded, so we'll do. * *		araj	 30-OCT-1986 17:21:38  *			Modified code so that esc [ ? o sp F *			does not get us out of JFY * *		araj	 3-NOV-1986 11:56:59  *			When we re-space a font, for instance *			to print a 10cpi font at 5cpi, *			the rightmost character should be lined *			up on the character box, not the  *			respaced box. * *//*  begin include_file    */#define cajfy (1)	    /* define for this file to get static vars. */#include    "portab.h"	    /* general portability constants */#include    "cpsys.hc"	    /* system wide constants, typedefs, etc. */#include    "cpast.hc"	    /* search tables				*/#include    "caglobal.hc"   /* global defs				*/#include    "camac.lib_hc"  /* Tempory macros for font functions	*/#ifdef DUMP  #include    "dumpu.hc"	    /* Dump Utility                             */#include    "xlc_iface.hc"  /* defines for oprintf			*/#endif DUMP/*  end   include_file    *//*****  enter_jfy()  **************************************************** *									* *	enter_jfy() - Reset the justify buffer index.			* ************************************************************************/VOID enter_jfy(){#ifdef DUMP{  return;}#endif    	/* Set the left anchor to a very high value (greater than any right    	   limit would be set).  The reason is if justify mode is on,     	   characters are in the justify buffer, and empty_jfy_buf() is called    	   without justification having been perfomed first, then the    	   test for adjustnment-necessary in empty_jfy_buf() will fail,    	   allowing the buffer to be emptied as fast as possible and without    	   alteration. */    	left_anchor = xl_st.h_lim_bound.max + 1;    	space_adj = 0;	xl_st.jfy_buf_index = 0;	/* Zero out buffer-store index */	left_char = 0;			/* Left most char is 0 */	right_char = -1;		/* Flags that the line */					/*has not been justified */}/*****  empty_jfy_buf()  ************************************************ *									* *	empty_jfy_buf() - Dispose of all current contents of the 	* *	justify buffer.  						* ************************************************************************/VOID empty_jfy_buf(){    WORD	cur_index;    LONG	cur_char_offset, max_ahp;    GLYPH	*gptr, vchar;/* If empty, forget it */if (xl_st.jfy_buf_index == 0)		return;/* Buffer is not empty, let's print it *//* Initialize some variables */	gptr = &xl_st.justify_buf[0];		/* Pointer to current character */cur_char_offset = 0;		/* Displacement in character 				   position caused by justification */max_ahp = left_anchor;		/* *//*   If the line was not justified (right_char == -1),    no adjustment is required, print things fast *//*   Note that a space_adj of 0 is not sufficient, as it could be    that the line was justified, but the width of spaces need no    modification. In such a case, we still drop trailing spaces */if (right_char == -1 ) 	{		/* print all characters as is */	for (cur_index = 0;  cur_index < xl_st.jfy_buf_index  ; cur_index++, gptr++)  		{		process_char(gptr);		}	/* reset things */	enter_jfy();		/* Indicate justify buffer is empty */	return;	}	/* First let's print the leading spaces without any modification */for (cur_index = 0;  cur_index < left_char ; cur_index++, gptr++)  	{	process_char(gptr);	}/* Now let's print the left anchor */	/* First move it left by an amount equal to it's left 	/* bearing so the character is aligned with the limit, 	/* not it's cell */	cur_char_offset = - get_left_bearing (gptr->char_data.char_code,             gptr->char_data.char_font);	gptr->ap.xval += cur_char_offset;	/*  Now let's remove all the line attributes of this	/*  character, as they may have to be shortened */	/*  Let's print the stripped character */	copy_glyph (gptr, &vchar);	vchar.font_data.algorithmic_attributes &= (~(UL | STRIKE | DOU_UL | OVERLINE));    	process_char(&vchar);/* Now let's print the attributes of the character */if ( gptr->font_data.algorithmic_attributes & (UL | STRIKE | DOU_UL | OVERLINE ) 	/* attributes on */   )	{	copy_glyph(gptr,&vchar);	vchar.char_data.char_code = VIR_CHAR_ADD;	vchar.char_data.char_width  -= cur_char_offset;	process_vchar(&vchar);	}gptr++;cur_index++;/* Output the contents of the justify buffer til right most character excluded */for ( ; cur_index < right_char; cur_index++, gptr++)  {	/* if the character is not a space */	if ((gptr->char_data.char_code != SP_C) && (gptr->char_data.char_code != VIR_CHAR_SPACE))	{		/* If this character was beyond the 		   highest ahp yet, record it. */		if (gptr->ap.xval > max_ahp)  max_ahp = gptr->ap.xval;		/* adjust the position of the character */		gptr->ap.xval += cur_char_offset;		/* 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) continue;		/* if it increases the max_ahp, 		   record the new ahp and include it		   in the correction factor and		   modify it's width  */		if ((gptr->ap.xval > max_ahp) && (gptr->char_data.char_code == SP_C))		{			max_ahp = gptr->ap.xval;					/* adjust the position of the character */			gptr->ap.xval += cur_char_offset;			/* It is within bounds, print it */			copy_glyph (gptr, &vchar);			vchar.char_data.char_code = VIR_CHAR_ADD;			vchar.char_data.char_width += space_adj;		    	process_vchar(&vchar);				/*Update the adjustment factor */			cur_char_offset += space_adj;			} /* End this space is a justifiable space */		else		{ /* This space does not increase ahp 		     print it, but do not adjust it */			/* adjust the position of the character */			gptr->ap.xval += cur_char_offset;			copy_glyph(gptr,&vchar);			vchar.char_data.char_code = VIR_CHAR_SPACE;			process_vchar(&vchar);				} /* End this space is not a justifiable space */		  /* End Space */		} /*End of characters (if_else space) */}	/*End of for loop *//* Let's print the right most character, but first, erase any attribute    that could overflow the right anchor *//* By definition, the right most character cannot be a space */    /*	If this character was beyond the 	highest ahp yet, record it. */    if (gptr->ap.xval > max_ahp)  max_ahp = gptr->ap.xval;    /* adjust the position of the character */    gptr->ap.xval += cur_char_offset;    /* Print the character  without its attributes */    copy_glyph(gptr,&vchar);    vchar.font_data.algorithmic_attributes  &= (~(UL | STRIKE | DOU_UL | OVERLINE ));        vchar.char_data.char_width = FNT_WIDTH(gptr->char_data.char_font,					   gptr->char_data.char_code);    process_char(&vchar);

⌨️ 快捷键说明

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