aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/tedit/display/curses/box.x
blob: 06eadbcd4e8405b0a74158573b8b19b3c8ed7b89 (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
include "../curses.h"
include "window.h"

# BOX -- Draw a box around a window
#
# B.Simon	01-Oct-90	Original

procedure box (win, vert, hor)

int	win		# i: Window descriptor
char	vert		# i: Character used for vertical side of window
char	hor		# i: Character used for horizontal side of window
#--
include "window.com"

int	vcode, hcode, rect[RSIZE]
pointer	pwin

begin
	# Don't box window if either dimension < 3 or window is already boxed

	pwin = warray[win]
	if (WIN_HEIGHT(pwin) < 3 || WIN_WIDTH(pwin) < 3 || 
	    WIN_BOXED(pwin) == YES)
	    return

	# Draw box

	vcode = vert
	hcode = hor

	RASG(rect, WIN_TOP(pwin), WIN_LEFT(pwin), 
	     WIN_TOP(pwin), WIN_RIGHT(pwin))
	call ps_fill (rect, hcode, WIN_ATRIB(pwin))

	RASG(rect, WIN_BOT(pwin), WIN_LEFT(pwin), 
	     WIN_BOT(pwin), WIN_RIGHT(pwin))
	call ps_fill (rect, hcode, WIN_ATRIB(pwin))

	RASG(rect, WIN_TOP(pwin), WIN_LEFT(pwin), 
	     WIN_BOT(pwin), WIN_LEFT(pwin))
	call ps_fill (rect, vcode, WIN_ATRIB(pwin))

	RASG(rect, WIN_TOP(pwin), WIN_RIGHT(pwin), 
	     WIN_BOT(pwin), WIN_RIGHT(pwin))
	call ps_fill (rect, vcode, WIN_ATRIB(pwin))

	# Reduce size of window's rectangle and mark as boxed

	WIN_TOP(pwin) = WIN_TOP(pwin) + 1
	WIN_LEFT(pwin) = WIN_LEFT(pwin) + 1
	WIN_BOT(pwin) = WIN_BOT(pwin) - 1
	WIN_RIGHT(pwin) = WIN_RIGHT(pwin) - 1
	WIN_BOXED(pwin) = YES

end