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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
############################################################################
#
# File: scater.icn
#
# Subject: Program to display visualize string concatenation
#
# Author: Ralph E. Griswold
#
# Date: March 1, 1997
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# This program displays successive numbers by lines of corresponding
# height. When the display area is full, it scrolls from right to
# left.
#
# In this version, input is piped in.
#
############################################################################
#
# Requires: Version 9 graphics, MT Icon and instrumentation
#
############################################################################
#
# Links: evinit, interact, vsetup
#
############################################################################
link evinit
link interact
link vsetup
global vidgets
global root
global strip
global state
global gc_black
global reset
global scale
global width
global height
global window
$include "evdefs.icn"
procedure main(args)
init(args)
display()
end
procedure init(args)
EvInit(args) | stop("*** cannot load SP.")
/EventSource := &eventsource
variable("write", EventSource) := -1
variable("writes", EventSource) := -1
window := WOpen ! ui_atts()
vidgets := ui()
root := vidgets["root"]
state := &null
scale := 1
width := vidgets["strip"].uw
height := vidgets["strip"].uh
strip := Clone(window, "dx=" || vidgets["strip"].ux, "dy=" ||
vidgets["strip"].uy)
Clip(strip, 0, 0, width, height)
gc_black := Clone(strip, "fg=black")
end
procedure display()
static cat, cmask, rmask
initial {
cat := proc("||", 2)
cmask := cset(E_Ocall)
rmask := cset(E_Oret)
}
repeat {
while (*Pending() > 0) | \state do
ProcessEvent(root, , shortcuts)
EvGet(cmask) | exit()
if &eventvalue === cat then {
EvGet(rmask) | exit()
&eventvalue := *&eventvalue
&eventvalue *:= scale
&eventvalue >:= height # Motif bug avoidance
CopyArea(strip, 1, 0, width - 1, height, 0, 0)
EraseArea(strip, width - 1, 0, width, height)
DrawLine(gc_black, width - 1, height - &eventvalue, width - 1, height)
}
}
end
procedure file_cb(vidget, value)
case value[1] of {
"snapshot @S": return snapshot(strip, 0, 0, width, height)
"quit @Q": exit()
}
fail
end
procedure configure_cb(vidget, value)
case value[1] of {
"scale": {
repeat {
if TextDialog(, "scale", scale, 10) == "Okay" then {
scale := (0 < numeric(dialog_value[1])) | {
Notice("Invalid scale value.")
next
}
reset_cb()
return
}
else fail # user canceled
}
}
}
fail
end
procedure reset_cb()
EraseArea(strip)
return
end
procedure shortcuts(e)
if &meta then
case map(e) of {
"q": exit()
"s": return snapshot(strip, 0, 0, width, height)
}
else fail
end
#===<<vib:begin>>=== modify using vib; do not remove this marker line
procedure ui_atts()
return ["size=477,255", "bg=gray-white"]
end
procedure ui(win, cbk)
return vsetup(win, cbk,
[":Sizer:::0,0,477,255:",],
["configure:Menu:pull::36,0,71,21:Configure",configure_cb,
["scale"]],
["file:Menu:pull::0,1,36,21:File",file_cb,
["snapshot @S","quit @Q"]],
["line1:Line:::0,22,477,22:",],
["reset:Button:regular::11,76,42,20:reset",reset_cb],
["strip:Rect:grooved::63,37,400,200:",],
)
end
#===<<vib:end>>=== end of section maintained by vib
|