aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/tedit/display/forms/fmredraw.x
blob: 71e5b7817c7c63c0ab84d49dfc2b159c5a3a9d7a (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
include	"formfn.h"
define	SZ_ESCSEQ	20

# FM_REDRAW -- Redraw the form

procedure fm_redraw (win, topfield)

int	win			# i: Window descriptor
int	topfield		# i: Top field on the form to draw
#--
int	nrows, ncols, botfield, ifield
pointer	sp, field, footer, escseq, data, name, value

begin
	# Allocate dynamic memory for strings

	call smark (sp)
	call salloc (field, SZ_LINE, TY_CHAR)
	call salloc (footer, SZ_LINE, TY_CHAR)
	call salloc (escseq, SZ_ESCSEQ, TY_CHAR)

	# Get form data structure

	call wgetstruct (win, data)

	# Get the dimensions of the form

	call wdimen (win, nrows, ncols)

	# Clear screen

	call werase (win)

	# Write the form

	name = FM_NAMPTR(data,topfield)
	value = FM_VALPTR(data,topfield)
	botfield = min (FM_NFIELD(data), topfield + FM_NPAGE(data) - 1)

	call wmove (win, 1, 1)
	do ifield = topfield, botfield {
	    call sprintf (Memc[field], SZ_LINE, "%*s = %s\n")
		call pargi (FM_LENNAM(data))
		call pargstr (Memc[name])
		call pargstr (Memc[value])

	    call waddstr (win, Memc[field])

	    name = name + FM_LENNAM(data) + 1
	    value = value + FM_LENVAL(data) + 1
	}

	# Write the footer line

	call k_eseq ("GET_HELP", Memc[escseq], SZ_ESCSEQ)

	call sprintf (Memc[footer], ncols, "%4w%s%*tHelp: %s%*t")
	call pargstr (FM_TITLE(data))
	call pargi (ncols-SZ_ESCSEQ)
	call pargstr (Memc[escseq])
	call pargi (ncols+1)

	call wmove (win, nrows, 1)
	call wstandout (win)
	call waddstr (win, Memc[footer])
	call wstandend (win)

	call sfree (sp)
end