Google
 

Trailing-Edge - PDP-10 Archives - bb-r775d-bm_tops20_ks_upd_4 - sources/wordwrap.bli
There are 10 other files named wordwrap.bli in the archive. Click here to see a list.
 %TITLE 'WORDWRAP - do word wrapping'
MODULE WORDWRAP (				! Do word wrapping
		IDENT = '3-001'			! File: WORDWRAP.BLI Edit: GB3001
		) =
BEGIN
!
!			  COPYRIGHT (c) 1981, 1985 BY
!	      DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
!		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 WHICH IS NOT SUPPLIED BY DIGITAL.
!

!++
! FACILITY:	EDT -- The DEC Standard Editor
!
! ABSTRACT:
!
!	This module trys to do word wrapping after an insert.
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: John Sauter, CREATION DATE: April 7, 1982
!
! MODIFIED BY:
!
! 1-001	- Original.  JBS 07-Apr-1982
! 1-002	- New screen update logic.  JBS 13-Sep-1982
! 1-003 - Add a parameter to split line routine.  SMB 16-Nov-1982
! 1-004 - Change the parameter to the split line routine.  SMB 17-Nov-1982
! 3-001 - Add updates from V3 sources.  GB 09-May-1983
!--

%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$WORD_WRAP;

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$WORD_WRAP - do word wrapping'

GLOBAL ROUTINE EDT$$WORD_WRAP 			! Do word wrapping
    =

!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine is called after text has been inserted to do word wrapping
!	if any is called for.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	LN_BUF
!	LN_PTR
!	LN_END
!	WD_WRAP
!
! IMPLICIT OUTPUTS:
!
!	NONE
!
! ROUTINE VALUE:
!
!	Always 1.
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$FMT_CHWID,
	EDT$$CS_LEFT,
	EDT$$CS_RIGHT,
	EDT$$FND_BWD,
	EDT$$SPLT_LNINS;

    EXTERNAL
	LN_BUF,				! Current line buffer.
	LN_PTR,				! Current character pointer.
	LN_END,				! End of current line pointer.
	WD_WRAP;				! Word wrap point.

    LOCAL
	CP,
	SAVE_POINT,
	DIFF,
	COL;

!+
! Do nothing if there is no word wrapping.
!-

    IF (.WD_WRAP NEQ 256)
    THEN
	BEGIN
!+
! Compute the current cursor position.
!-
	COL = 0;
	CP = CH$PTR (LN_BUF,, BYTE_SIZE);

	WHILE CH$PTR_NEQ (.CP, .LN_PTR) DO
	    COL = .COL + EDT$$FMT_CHWID (CH$RCHAR_A (CP), .COL);

!+
! If the current column is beyond the wrap point, wrap the line.
!-

	IF (.COL GTR .WD_WRAP)
	THEN
	    BEGIN
	    SAVE_POINT = .LN_PTR;
	    EDT$$CS_LEFT ();

	    IF (CH$RCHAR (.LN_PTR) EQL %C' ') THEN EDT$$CS_RIGHT () ELSE EDT$$FND_BWD (1);

	    DIFF = CH$DIFF (.SAVE_POINT, .LN_PTR);

	    IF CH$PTR_NEQ (.LN_PTR, CH$PTR (LN_BUF,, BYTE_SIZE)) THEN EDT$$SPLT_LNINS (1);

	    LN_PTR = CH$PLUS (.LN_PTR, .DIFF);
	    END;

	END;

    RETURN (1);
    END;					! of routine EDT$$WORD_WRAP


END
ELUDOM