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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
|
implement Srvbrowse;
#
# Copyright © 2003 Vita Nuova Holdings Limited. All rights reserved.
#
include "sys.m";
sys : Sys;
include "draw.m";
draw: Draw;
Rect: import draw;
include "tk.m";
tk: Tk;
include "tkclient.m";
tkclient: Tkclient;
include "grid/srvbrowse.m";
include "registries.m";
registries: Registries;
Registry, Attributes, Service: import registries;
init()
{
sys = load Sys Sys->PATH;
if (sys == nil)
badmod(Sys->PATH);
draw = load Draw Draw->PATH;
if (draw == nil)
badmod(Draw->PATH);
tk = load Tk Tk->PATH;
if (tk == nil)
badmod(Tk->PATH);
tkclient = load Tkclient Tkclient->PATH;
if (tkclient == nil)
badmod(Tkclient->PATH);
tkclient->init();
registries = load Registries Registries->PATH;
if (registries == nil)
badmod(Registries->PATH);
registries->init();
reg = Registry.new("/mnt/registry");
if (reg == nil) {
reg = Registry.connect(nil, nil, nil);
if (reg == nil)
error("Could not find registry");
}
qids = array[511] of { * => "" };
}
reg : ref Registry;
qids : array of string;
# Qid stuff is a bit rubbish at the mo but waiting for registries to change:
# currently address is unique but will not be in the future so waiting
# for another id to uniquely identify a resource
addqid(srvc: ref Service): int
{
addr := srvc.addr;
qid := addr2qid(addr);
for (;;) {
if (qids[qid] == nil)
break;
else if (qids[qid] == addr)
return qid;
qid++;
if (qid >= len qids)
qid = 0;
}
qids[qid] = addr;
# sys->print("adding %s (%s) to %d\n",srvc.attrs.get("resource"), addr, qid);
return qid;
}
getqid(srvc: ref Service): string
{
addr := srvc.addr;
qid := addr2qid(addr);
startqid := qid;
for (;;) {
if (qids[qid] == addr)
return string qid;
qid++;
if (qid == startqid)
break;
if (qid >= len qids)
qid = 0;
}
return nil;
}
addr2qid(addr: string): int
{
qid := 0;
# assume addr starts 'tcp!...'
for (i := 4; i < len addr; i++) {
qid += addr[i] * 2**(i%10);
qid = qid % len qids;
}
return qid;
}
addservice(srvc: ref Service)
{
services = srvc :: services;
addqid(srvc);
}
find(filter: list of list of (string, string)): list of ref Service
{
lsrv : list of ref Service = nil;
if (filter == nil)
(lsrv, nil) = reg.services();
else {
for (; filter != nil; filter = tl filter) {
attr := hd filter;
(s, err) := reg.find(attr);
for (; s != nil; s = tl s)
lsrv = hd s :: lsrv;
}
}
return sortservices(lsrv);
}
refreshservices(filter: list of list of (string, string))
{
services = find(filter);
}
servicepath2Service(path, qid: string): list of ref Service
{
srvl : list of ref Service = nil;
(nil, lst) := sys->tokenize(path, "/");
pname: string;
l := len lst;
if (l < 2 || l > 3)
return nil;
presource := hd tl lst;
if (l == 3)
pname = hd tl tl lst;
for (tmpl := services; tmpl != nil; tmpl = tl tmpl) {
srvc := hd tmpl;
(resource, name) := getresname(srvc);
if (l == 2) {
if (resource == presource)
srvl = srvc :: srvl;
}
else if (l == 3) {
if (resource == presource) {
if (name == pname && qid == getqid(srvc)) {
srvl = srvc :: srvl;
break;
}
}
}
}
return srvl;
}
servicepath2Dir(path: string, qid: int): (array of ref sys->Dir, int)
{
# sys->print("srvcPath2Dir: '%s' %d\n",path, qid);
res : list of (string, string) = nil;
(nil, lst) := sys->tokenize(path, "/");
presource, pname: string;
pattrib := 0;
l := len lst;
if (l > 1)
presource = hd tl lst;
if (l > 2)
pname = hd tl tl lst;
if (l == 4 && hd tl tl tl lst == "attributes")
pattrib = 1;
for (tmpl := services; tmpl != nil; tmpl = tl tmpl) {
srvc := hd tmpl;
(resource, name) := getresname(srvc);
if (l == 1) {
if (!isin(res, resource))
res = (resource, nil) :: res;
}
else if (l == 2) {
if (resource == presource)
res = (name, string getqid(srvc)) :: res;
}
else if (l == 3) {
if (resource == presource && name == pname) {
if (qid == int getqid(srvc)) {
if (srvc.addr[0] == '@')
res = (srvc.addr[1:], string getqid(srvc)) :: res;
else {
if (srvc.attrs != nil)
res = ("attributes", string getqid(srvc)) :: res;
res = ("address:\0"+srvc.addr+"}", string getqid(srvc)) :: res;
}
break;
}
}
}
else if (l == 4) {
if (resource == presource && name == pname && pattrib) {
if (qid == int getqid(srvc)) {
for (tmpl2 := srvc.attrs.attrs; tmpl2 != nil; tmpl2 = tl tmpl2) {
(attrib, val) := hd tmpl2;
if (attrib != "name" && attrib != "resource")
res = (attrib+":\0"+val, string getqid(srvc)) :: res;
}
break;
}
}
}
}
resa := array [len res] of ref sys->Dir;
i := len resa - 1;
for (; res != nil; res = tl res) {
dir : sys->Dir;
qid: string;
(dir.name, qid) = hd res;
if (l < 3 || dir.name == "attributes")
dir.mode = 8r777 | sys->DMDIR;
else
dir.mode = 8r777;
if (qid != nil)
dir.qid.path = big qid;
resa[i--] = ref dir;
}
dups := 0;
if (l >= 2)
dups = 1;
return (resa, dups);
}
isin(l: list of (string, string), s: string): int
{
for (; l != nil; l = tl l)
if ((hd l).t0 == s)
return 1;
return 0;
}
getresname(srvc: ref Service): (string, string)
{
resource := srvc.attrs.get("resource");
if (resource == nil)
resource = "Other";
name := srvc.attrs.get("name");
if (name == nil)
name = "?????";
return (resource,name);
}
badmod(path: string)
{
sys->print("Srvbrowse: failed to load: %s\n",path);
exit;
}
sortservices(lsrv: list of ref Service): list of ref Service
{
a := array[len lsrv] of ref Service;
i := 0;
for (; lsrv != nil; lsrv = tl lsrv) {
addqid(hd lsrv);
a[i++] = hd lsrv;
}
heapsort(a);
lsrvsorted: list of ref Service = nil;
for (i = len a - 1; i >= 0; i--)
lsrvsorted = a[i] :: lsrvsorted;
return lsrvsorted;
}
heapsort(a: array of ref Service)
{
for (i := (len a / 2) - 1; i >= 0; i--)
movedownheap(a, i, len a - 1);
for (i = len a - 1; i > 0; i--) {
tmp := a[0];
a[0] = a[i];
a[i] = tmp;
movedownheap(a, 0, i - 1);
}
}
movedownheap(a: array of ref Service, root, end: int)
{
max: int;
while (2*root <= end) {
r2 := root * 2;
if (2*root == end || comp(a[r2], a[r2+1]) == GT)
max = r2;
else
max = r2 + 1;
if (comp(a[root], a[max]) == LT) {
tmp := a[root];
a[root] = a[max];
a[max] = tmp;
root = max;
}
else
break;
}
}
LT: con -1;
EQ: con 0;
GT: con 1;
comp(a1, a2: ref Service): int
{
(resource1, name1) := getresname(a1);
(resource2, name2) := getresname(a2);
if (resource1 < resource2)
return LT;
if (resource1 > resource2)
return GT;
if (name1 < name2)
return LT;
if (name1 > name2)
return GT;
return EQ;
}
error(e: string)
{
sys->fprint(sys->fildes(2), "Srvbrowse: %s\n", e);
raise "fail:error";
}
searchscr := array[] of {
"frame .f",
"scrollbar .f.sy -command {.f.c yview}",
"scrollbar .f.sx -command {.f.c xview} -orient horizontal",
"canvas .f.c -yscrollcommand {.f.sy set} -xscrollcommand {.f.sx set} -bg white -width 414 -borderwidth 2 -relief sunken -height 180 -xscrollincrement 10 -yscrollincrement 19",
"grid .f.sy -row 0 -column 0 -sticky ns -rowspan 2",
"grid .f.sx -row 1 -column 1 -sticky ew",
"grid .f.c -row 0 -column 1",
"pack .f -fill both -expand 1 ; pack propagate . 0; update",
};
SEARCH, RESULTS: con iota;
searchwin(ctxt: ref Draw->Context, chanout: chan of string, filter: list of list of (string, string))
{
(top, titlebar) := tkclient->toplevel(ctxt,"","Search", tkclient->Appl);
butchan := chan of string;
tk->namechan(top, butchan, "butchan");
tkcmds(top, searchscr);
makesearchframe(top);
flid := setframe(top, ".fsearch", nil);
selected := "";
lresults : list of ref Service = nil;
resultstart := 0;
resize(top, 368,220);
maxresults := getmaxresults(top);
currmode := SEARCH;
tkclient->onscreen(top, nil);
tkclient->startinput(top, "kbd"::"ptr"::nil);
main: for (;;) {
alt {
s := <-top.ctxt.kbd =>
tk->keyboard(top, s);
s := <-top.ctxt.ptr =>
tk->pointer(top, *s);
inp := <-butchan =>
(nil, lst) := sys->tokenize(inp, " ");
case hd lst {
"key" =>
s := " ";
id := hd tl lst;
nv := hd tl tl lst;
tkp : string;
if (id != "-1")
tkp = ".fsearch.ea"+nv+id;
else
tkp = ".fsearch.e"+nv;
char := int hd tl tl tl lst;
s[0] = char;
if (char == '\n' || char == '\t') {
newtkp := ".fsearch";
if (nv == "n")
newtkp += ".eav"+id;
else if (nv == "v") {
newid := string ((int id)+1);
e := tk->cmd(top, ".fsearch.ean"+newid+" cget -width");
if (e == "" || e[0] == '!') {
insertattribrow(top);
newtkp += ".ean"+newid;
}
else
newtkp += ".ean"+newid;
}
focus(top, newtkp);
}
else {
tkcmd(top, tkp+" insert insert {"+s+"}");
tkcmd(top, tkp+" see "+tkcmd(top, tkp+" index insert"));
}
"go" =>
lresults = search(top, filter);
resultstart = 0;
makeresultsframe(top, lresults, 0, maxresults);
selected = nil;
flid = setframe(top, ".fresults", flid);
currmode = RESULTS;
if (chanout != nil)
chanout <-= "search search";
"prev" =>
selected = nil;
resultstart -= maxresults;
if (resultstart < 0)
resultstart = 0;
makeresultsframe(top, lresults, resultstart, maxresults);
flid = setframe(top, ".fresults", flid);
"next" =>
selected = nil;
if (resultstart < 0)
resultstart = 0;
resultstart += maxresults;
if (resultstart >= len lresults)
resultstart -= maxresults;
makeresultsframe(top, lresults, resultstart, maxresults);
flid = setframe(top, ".fresults", flid);
"backto" =>
flid = setframe(top, ".fsearch", flid);
tkcmd(top, ".f.c see 0 "+tkcmd(top, ".fsearch cget -height"));
currmode = SEARCH;
"new" =>
resetsearchscr(top);
tkcmd(top, ".f.c see 0 0");
setscrollr(top, ".fsearch");
"select" =>
if (selected != nil)
tkcmd(top, selected+" configure -bg white");
if (selected == hd tl lst)
selected = nil;
else {
selected = hd tl lst;
tkcmd(top, hd tl lst+" configure -bg #5555FF");
if (chanout != nil)
chanout <-= "search select " +
tkcmd(top, selected+" cget -text") + " " + hd tl tl lst;
}
}
tkcmd(top, "update");
title := <-top.ctxt.ctl or
title = <-top.wreq or
title = <-titlebar =>
if (title == "exit" || title == "ok")
break main;
e := tkclient->wmctl(top, title);
if (e == nil && title[0] == '!') {
(nil, lst) := sys->tokenize(title, " \t\n");
if (len lst >= 2 && hd lst == "!size" && hd tl lst == ".") {
resize(top, -1,-1);
maxresults = getmaxresults(top);
if (currmode == RESULTS) {
makeresultsframe(top, lresults, resultstart, maxresults);
flid = setframe(top, ".fresults", flid);
tkcmd(top, "update");
}
}
}
}
}
}
getmaxresults(top: ref Tk->Toplevel): int
{
val := ((int tkcmd(top, ".f.c cget -height")) - 65)/17;
if (val < 1)
return 1;
return val;
}
setframe(top: ref Tk->Toplevel, f, oldflid: string): string
{
if (oldflid != nil)
tkcmd(top, ".f.c delete " + oldflid);
newflid := tkcmd(top, ".f.c create window 0 0 -window "+f+" -anchor nw");
setscrollr(top, f);
return newflid;
}
setscrollr(top: ref Tk->Toplevel, f: string)
{
h := tkcmd(top, f+" cget -height");
w := tkcmd(top, f+" cget -width");
tkcmd(top, ".f.c configure -scrollregion {0 0 "+w+" "+h+"}");
}
resize(top: ref Tk->Toplevel, width, height: int)
{
if (width == -1) {
width = int tkcmd(top, ". cget -width");
height = int tkcmd(top, ". cget -height");
}
else
tkcmd(top, sys->sprint(". configure -width %d -height %d", width, height));
htitle := int tkcmd(top, ".f cget -acty") - int tkcmd(top, ". cget -acty");
height -= htitle;
ws := int tkcmd(top, ".f.sy cget -width");
hs := int tkcmd(top, ".f.sx cget -height");
tkcmd(top, ".f.c configure -width "+string (width - ws - 8)+
" -height "+string (height - hs - 8));
tkcmd(top, "update");
}
makesearchframe(top: ref Tk->Toplevel)
{
font := " -font /fonts/charon/plain.normal.font";
fontb := " -font /fonts/charon/bold.normal.font";
f := ".fsearch";
tkcmd(top, "frame "+f+" -bg white");
tkcmd(top, "label "+f+".l -text {Search for Resource Attributes} -bg white" + fontb);
tkcmd(top, "grid "+f+".l -row 0 -column 0 -columnspan 3 -sticky nw");
tkcmd(top, "grid rowconfigure "+f+" 0 -minsize 30");
tkcmd(top, "frame "+f+".fgo -bg white");
tkcmd(top, "button "+f+".bs -text {Search} -command {send butchan go} "+font);
tkcmd(top, "button "+f+".bc -text {Clear} -command {send butchan new} "+font);
tkcmd(top, "grid "+f+".bs -row 3 -column 0 -sticky e -padx 2 -pady 5");
tkcmd(top, "grid "+f+".bc -row 3 -column 1 -sticky w -pady 5");
tkcmd(top, "label "+f+".la1 -text {name} -bg white "+fontb);
tkcmd(top, "label "+f+".la2 -text {value} -bg white "+fontb);
tkcmd(top, "grid "+f+".la1 "+f+".la2 -row 1");
insertattribrow(top);
}
insertattribrow(top: ref Tk->Toplevel)
{
(n, nil) := sys->tokenize(tkcmd(top, "grid slaves .fsearch -column 1"), " \t\n");
row := string (n);
sn := string (n - 2);
fsn := ".fsearch.ean"+sn;
fsv := ".fsearch.eav"+sn;
font := " -font /fonts/charon/plain.normal.font";
tkcmd(top, "entry "+fsn+" -width 170 -borderwidth 0 "+font);
tkcmd(top, "bind "+fsn+" <Key> {send butchan key "+sn+" n %s}");
tkcmd(top, "entry "+fsv+" -width 170 -borderwidth 0 "+font);
tkcmd(top, "bind "+fsv+" <Key> {send butchan key "+sn+" v %s}");
tkcmd(top, "grid rowinsert .fsearch "+row);
tkcmd(top, "grid "+fsn+" -column 0 -row "+row+" -sticky w -pady 1 -padx 2");
tkcmd(top, "grid "+fsv+" -column 1 -row "+row+" -sticky w -pady 1");
setscrollr(top, ".fsearch");
}
min(a,b: int): int
{
if (a < b)
return a;
return b;
}
max(a,b: int): int
{
if (a > b)
return a;
return b;
}
makeresultsframe(top: ref Tk->Toplevel, lsrv: list of ref Service, resultstart, maxresults: int)
{
font := " -font /fonts/charon/plain.normal.font";
fontb := " -font /fonts/charon/bold.normal.font";
f := ".fresults";
nresults := len lsrv;
row := 0;
n := 0;
tk->cmd(top, "destroy "+f);
tkcmd(top, "frame "+f+" -bg white");
title := "Search Results";
if (nresults > 0) {
from := resultstart+1;
too := min(resultstart+maxresults, nresults);
if (from == too)
title += sys->sprint(" (displaying match %d of %d)", from, nresults);
else
title += sys->sprint(" (displaying matches %d - %d of %d)", from, too, nresults);
}
tkcmd(top, "label "+f+".l -text {"+title+"} -bg white -anchor w" + fontb);
w1 := int tkcmd(top, f+".l cget -width");
w2 := int tkcmd(top, ".f.c cget -width");
tkcmd(top, f+".l configure -width "+string max(w1,w2));
tkcmd(top, "grid "+f+".l -row 0 -column 0 -columnspan 3 -sticky nw");
tkcmd(top, "grid rowconfigure "+f+" 0 -minsize 30");
tkcmd(top, "frame "+f+".f -bg white");
for (; lsrv != nil; lsrv = tl lsrv) {
if (n >= resultstart && n < resultstart + maxresults) {
srvc := hd lsrv;
(resource, name) := getresname(srvc);
qid := getqid(srvc);
if (qid == nil)
qid = string addqid(srvc);
label := f+".f.lQ"+qid;
tkcmd(top, "label "+label+" -bg white -text {services/"+
resource+"/"+name+"/}"+font);
tkcmd(top, "grid "+label+" -row "+string row+" -column 0 -sticky w");
tkcmd(top, "bind "+label+" <Button-1> {send butchan select "+label+" "+qid+"}");
row++;
}
n++;
}
if (nresults == 0) {
tkcmd(top, "label "+f+".f.l0 -bg white -text {No matches found}"+font);
tkcmd(top, "grid "+f+".f.l0 -row 0 -column 0 -columnspan 3 -sticky w");
}
else {
tkcmd(top, "button "+f+".bprev -text {<<} "+
"-command {send butchan prev}"+font);
if (resultstart == 0)
tkcmd(top, f+".bprev configure -state disabled");
tkcmd(top, "button "+f+".bnext -text {>>} "+
"-command {send butchan next}"+font);
if (resultstart + maxresults >= nresults)
tkcmd(top, f+".bnext configure -state disabled");
tkcmd(top, "grid "+f+".bprev -column 0 -row 2 -padx 5 -pady 5");
tkcmd(top, "grid "+f+".bnext -column 2 -row 2 -padx 5 -pady 5");
}
tkcmd(top, "grid "+f+".f -row 1 -column 0 -columnspan 3 -sticky nw");
tkcmd(top, "grid rowconfigure "+f+" 1 -minsize "+string (maxresults*17));
tkcmd(top, "button "+f+".bsearch -text {Back to Search} "+
"-command {send butchan backto}"+font);
tkcmd(top, "grid "+f+".bsearch -column 1 -row 2 -padx 5 -pady 5");
}
focus(top: ref Tk->Toplevel, newtkp: string)
{
tkcmd(top, "focus "+newtkp);
x1 := int tkcmd(top, newtkp + " cget -actx")
- int tkcmd(top, ".fsearch cget -actx");
y1 := int tkcmd(top, newtkp + " cget -acty")
- int tkcmd(top, ".fsearch cget -acty");
x2 := x1 + int tkcmd(top, newtkp + " cget -width");
y2 := y1 + int tkcmd(top, newtkp + " cget -height") + 45;
tkcmd(top, sys->sprint(".f.c see %d %d %d %d", x1,y1-30,x2,y2));
}
search(top: ref Tk->Toplevel, filter: list of list of (string, string)): list of ref Service
{
searchattrib: list of (string, string) = nil;
(n, nil) := sys->tokenize(tkcmd(top, "grid slaves .fsearch -column 0"), " \t\n");
for (i := 0; i < n - 3; i++) {
attrib := tkcmd(top, ".fsearch.ean"+string i+" get");
val := tkcmd(top, ".fsearch.eav"+string i+" get");
if (val == nil)
val = "*";
if (attrib != nil)
searchattrib = (attrib, val) :: searchattrib;
}
tmp : list of list of (string, string) = nil;
for (; filter != nil; filter = tl filter) {
l := hd filter;
for (tmp2 := searchattrib; tmp2 != nil; tmp2 = tl tmp2)
l = hd tmp2 :: l;
tmp = l :: tmp;
}
filter = tmp;
if (filter == nil)
filter = searchattrib :: nil;
return find(filter);
}
getitem(l : list of (string, ref Service), testid: string): ref Service
{
for (; l != nil; l = tl l) {
(id, srvc) := hd l;
if (testid == id)
return srvc;
}
return nil;
}
delitem(l : list of (string, ref Service), testid: string): list of (string, ref Service)
{
l2 : list of (string, ref Service) = nil;
for (; l != nil; l = tl l) {
(id, srvc) := hd l;
if (testid != id)
l2 = (id, srvc) :: l2;
}
return l2;
}
resetsearchscr(top: ref Tk->Toplevel)
{
(n, nil) := sys->tokenize(tkcmd(top, "grid slaves .fsearch -column 1"), " \t\n");
for (i := 1; i < n - 2; i++)
tkcmd(top, "destroy .fsearch.ean"+string i+" .fsearch.eav"+string i);
s := " delete 0 end";
tkcmd(top, ".fsearch.ean0"+s);
tkcmd(top, ".fsearch.eav0"+s);
}
tkcmd(top: ref Tk->Toplevel, cmd: string): string
{
e := tk->cmd(top, cmd);
if (e != "" && e[0] == '!')
sys->print("Tk error: '%s': %s\n",cmd,e);
return e;
}
tkcmds(top: ref Tk->Toplevel, a: array of string)
{
for (j := 0; j < len a; j++)
tkcmd(top, a[j]);
}
|