scrn-fld.lua /size: 4435 b    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
scrn-fld
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to scrn-fld.mkiv
"
,
4
author
=
"
Hans Hagen, PRAGMA-ADE, Hasselt NL
"
,
5
copyright
=
"
PRAGMA ADE / ConTeXt Development Team
"
,
6
license
=
"
see context related readme files
"
7
}
8 9
-- we should move some code from lpdf-fld to here
10 11
local
context
=
context
12
local
ctx_doifelse
=
commands
.
doifelse
13
local
implement
=
interfaces
.
implement
14 15
local
variables
=
interfaces
.
variables
16
local
v_yes
=
variables
.
yes
17 18
local
report
=
logs
.
reporter
(
"
widgets
"
)
19 20
local
texsetbox
=
tex
.
setbox
21 22
local
fields
=
{
}
23
interactions
.
fields
=
fields
24 25
local
codeinjections
=
backends
.
codeinjections
26
local
nodeinjections
=
backends
.
nodeinjections
27 28
local
function
define
(
specification
)
29
codeinjections
.
definefield
(
specification
)
30
end
31 32
local
function
defineset
(
name
,
set
)
33
codeinjections
.
definefield
(
name
,
set
)
34
end
35 36
local
function
clone
(
specification
)
37
codeinjections
.
clonefield
(
specification
)
38
end
39 40
local
function
insert
(
name
,
specification
)
41
return
nodeinjections
.
typesetfield
(
name
,
specification
)
42
end
43 44
fields
.
define
=
define
45
fields
.
defineset
=
defineset
46
fields
.
clone
=
clone
47
fields
.
insert
=
insert
48 49
-- codeinjections are not yet defined
50 51
implement
{
52
name
=
"
definefield
"
,
53
actions
=
define
,
54
arguments
=
{
55
{
56
{
"
name
"
}
,
57
{
"
alternative
"
}
,
58
{
"
type
"
}
,
59
{
"
category
"
}
,
60
{
"
values
"
}
,
61
{
"
default
"
}
,
62
}
63
}
64
}
65 66
implement
{
67
name
=
"
definefieldset
"
,
68
actions
=
defineset
,
69
arguments
=
"
2 strings
"
,
70
}
71 72
implement
{
73
name
=
"
clonefield
"
,
74
actions
=
clone
,
75
arguments
=
{
76
{
77
{
"
children
"
}
,
78
{
"
alternative
"
}
,
79
{
"
parent
"
}
,
80
{
"
category
"
}
,
81
{
"
values
"
}
,
82
{
"
default
"
}
,
83
}
84
}
85
}
86 87
implement
{
88
name
=
"
insertfield
"
,
89
actions
=
function
(
name
,
specification
)
90
local
b
=
insert
(
name
,
specification
)
91
if
b
then
92
texsetbox
(
"
b_scrn_field_body
"
,
b
)
93
else
94
report
(
"
unknown field %a
"
,
name
)
95
end
96
end
,
97
arguments
=
{
98
"
string
"
,
99
{
100
{
"
title
"
}
,
101
{
"
width
"
,
"
dimen
"
}
,
102
{
"
height
"
,
"
dimen
"
}
,
103
{
"
depth
"
,
"
dimen
"
}
,
104
{
"
align
"
}
,
105
{
"
length
"
}
,
106
{
"
fontstyle
"
}
,
107
{
"
fontalternative
"
}
,
108
{
"
fontsize
"
}
,
109
{
"
fontsymbol
"
}
,
110
{
"
colorvalue
"
,
"
integer
"
}
,
111
{
"
color
"
}
,
112
{
"
backgroundcolorvalue
"
,
"
integer
"
}
,
113
{
"
backgroundcolor
"
}
,
114
{
"
framecolorvalue
"
,
"
integer
"
}
,
115
{
"
framecolor
"
}
,
116
{
"
layer
"
}
,
117
{
"
option
"
}
,
118
{
"
align
"
}
,
119
{
"
clickin
"
}
,
120
{
"
clickout
"
}
,
121
{
"
regionin
"
}
,
122
{
"
regionout
"
}
,
123
{
"
afterkey
"
}
,
124
{
"
format
"
}
,
125
{
"
validate
"
}
,
126
{
"
calculate
"
}
,
127
{
"
focusin
"
}
,
128
{
"
focusout
"
}
,
129
{
"
openpage
"
}
,
130
{
"
closepage
"
}
,
131
}
132
}
133
}
134 135
-- (for the monent) only tex interface
136 137
implement
{
138
name
=
"
getfieldcategory
"
,
139
arguments
=
"
string
"
,
140
actions
=
function
(
name
)
141
local
g
=
codeinjections
.
getfieldcategory
(
name
)
142
if
g
then
143
context
(
g
)
144
end
145
end
146
}
147 148
implement
{
149
name
=
"
getdefaultfieldvalue
"
,
150
arguments
=
"
string
"
,
151
actions
=
function
(
name
)
152
local
d
=
codeinjections
.
getdefaultfieldvalue
(
name
)
153
if
d
then
154
context
(
d
)
155
end
156
end
157
}
158 159
implement
{
160
name
=
"
exportformdata
"
,
161
arguments
=
"
string
"
,
162
actions
=
function
(
export
)
163
if
export
=
=
v_yes
then
164
codeinjections
.
exportformdata
(
)
165
end
166
end
167
}
168 169
implement
{
170
name
=
"
setformsmethod
"
,
171
arguments
=
"
string
"
,
172
actions
=
function
(
method
)
173
codeinjections
.
setformsmethod
(
method
)
174
end
175
}
176 177
implement
{
178
name
=
"
doifelsefieldcategory
"
,
179
arguments
=
"
string
"
,
180
actions
=
function
(
name
)
181
ctx_doifelse
(
codeinjections
.
validfieldcategory
(
name
)
)
182
end
183
}
184 185
implement
{
186
name
=
"
doiffieldsetelse
"
,
187
arguments
=
"
string
"
,
188
actions
=
function
(
name
)
189
ctx_doifelse
(
codeinjections
.
validfieldset
(
name
)
)
190
end
191
}
192