aboutsummaryrefslogtreecommitdiff
path: root/sys/psio/psbreak.x
blob: eb82b5411040bc441dc40aceae4b362c1d912669 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include <psset.h>
include "psio.h"


# PS_LINEBREAK -- Break the current line regardless of whether it has been
# filled.  The fill_flag says whether to fill the current line to be right 
# justified.  May be called to simply output the current line buffer.

procedure ps_linebreak (ps, fill_flag)

pointer	ps					#I PSIO descriptor
int	fill_flag				#I fill line flag

begin
	iferr (call ps_output (ps, Memc[PS_WBPTR(ps)], fill_flag))
	    return

	# Do a variable spacing depending on whether we're within unformatted
	# text where the font is smaller, or outputting a regular line.

	if (PS_CFONT(ps) == F_TELETYPE)
            PS_YPOS(ps) = PS_YPOS(ps) - ((LINE_HEIGHT-2) * RESOLUTION)
	else 
            PS_YPOS(ps) = PS_YPOS(ps) - (LINE_HEIGHT * RESOLUTION)

	# Check for a page break.
        if (PS_YPOS(ps) <= PS_PBMARGIN(ps))
            call ps_pagebreak (ps)
	else {
	    call fprintf (PS_FD(ps), "%d V\n")
	        call pargi (PS_YPOS(ps))
	}

        # Reset the X position to current left margin.
        PS_XPOS(ps) = PS_CLMARGIN(ps)

	# Clear the word buffer.
	call aclrc (Memc[PS_WBPTR(ps)], SZ_LINE)
end


# PS_NEWLINE -- Output a newline (vertical space actually).

procedure ps_newline (ps)

pointer	ps					#I PSIO descriptor

begin
	# Check for a page break.
        PS_YPOS(ps) = PS_YPOS(ps) - ((LINE_HEIGHT-4) * RESOLUTION)
        if (PS_YPOS(ps) <= PS_PBMARGIN(ps))
            call ps_pagebreak (ps)
	else {
	    call fprintf (PS_FD(ps), "%d V\n")
	        call pargi (PS_YPOS(ps))
	}

        # Reset the X position to current left margin.
        PS_XPOS(ps) = PS_CLMARGIN(ps)
end


# PS_PAGEBREAK -- Break the current page regardless of whether it has been
# filled.

procedure ps_pagebreak (ps)

pointer	ps					#I PSIO descriptor

begin
	PS_PNUM(ps) = PS_PNUM(ps) + 1
	call fprintf (PS_FD(ps), "EP\n%%%%Page: %d %d\nBP\n")
	    call pargi (PS_PNUM(ps))
	    call pargi (PS_PNUM(ps))

	PS_YPOS(ps) = (PS_PHEIGHT(ps) * RESOLUTION) - PS_PTMARGIN(ps)
	call ps_ypos (ps, PS_YPOS(ps))
end