aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/tedit/display/curses/getscreen.x
blob: 58020c3f66439e823f11870a96cd6bb49fcc0d5c (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
include	"../curses.h"

# GETSCREEN -- Retrieve screen contents into a window's buffer
#
# B.Simon	26-Sep-90	Original

procedure getscreen (source, buffer)

int	source[RSIZE]	# i: Rectangle to be retrieved
pointer	buffer		# o: Buffer (allocated by this routine)
#--

int	dest[RSIZE]
int	maxcol, maxrow, ncols, nrows, irow
pointer	buf, scr

bool	ps_intersect()
int	ps_width(), ps_height()
pointer	ps_screen()

begin
	# Clip the rectangle to the screen boundary
	# If the rectangle is entirely off the screen, return

	buffer = NULL
	maxcol = ps_width ()
	maxrow = ps_height ()
	if (! ps_intersect (source, maxrow, maxcol, dest))
	    return

	# Allocate buffer to hold screen contents

	ncols = RWIDTH(dest)
	nrows = RHEIGHT(dest)
	call malloc (buffer, ncols*nrows, TY_CHAR)

	# Copy screen contents to buffer

	buf = buffer
	scr = ps_screen (RTOP(dest), RLEFT(dest))

	do irow = RTOP(dest), RBOT(dest) {
	    call amovc (Memc[scr], Memc[buf], ncols)
	    scr = scr + maxcol
	    buf = buf + ncols
	}

end