summaryrefslogtreecommitdiff
path: root/comms/pilot-link/patches/patch-ae
blob: daf152cfc424f72dedd0972e0005574addd5f990 (plain)
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
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
$NetBSD: patch-ae,v 1.4 2003/09/28 15:09:50 tron Exp $

--- src/pilot-debug.c.orig	2002-12-02 15:32:47.000000000 +0100
+++ src/pilot-debug.c	2003-09-28 17:08:23.000000000 +0200
@@ -1549,526 +1549,524 @@
     return TCL_OK;
   }
 
-  Tcl_VarEval(interp,"\
-
-###  /*** Generate remote UI window ***/
-
-set tkdbg 1
-
-toplevel .remote
-wm title .remote {Palm Remote UI}
-
-catch {
-	if {[file exists {tools/pix/case.gif}]} {
-		set dir {tools}
-	} elseif {[file exists {",LIBDIR,"/pix/case.gif}]} {
-		set dir {",LIBDIR,"/pix}
-	} else {
-		error {No pix}
-	}
-	image create photo Case -format gif -file \"$dir/pix/case.gif\"
-	image create photo B1 -format gif -file \"$dir/pix/b1.gif\"
-	image create photo B2 -format gif -file \"$dir/pix/b2.gif\"
-	image create photo B3 -format gif -file \"$dir/pix/b3.gif\"
-	image create photo B4 -format gif -file \"$dir/pix/b4.gif\"
-	image create photo B5 -format gif -file \"$dir/pix/b5.gif\"
-	image create photo B6 -format gif -file \"$dir/pix/b6.gif\"
-	image create photo B7 -format gif -file \"$dir/pix/b7.gif\"
-}
-
-canvas .remote.c -width 221 -height 337
-
-.remote.c create rectangle 27 29 196 260 -outline {red} -tag screen -fill {blue}
-.remote.c create rectangle 0 280 18 306 -outline {red} -tag button1 -fill {blue}
-.remote.c create oval 23 276 52 307 -outline {red} -tag button2 -fill {blue}
-.remote.c create oval 63 276 92 307 -outline {red} -tag button3 -fill {blue}
-.remote.c create rectangle 97 277 127 294 -outline {red} -tag button4 -fill {blue}
-.remote.c create rectangle 97 300 127 317 -outline {red} -tag button5 -fill {blue}
-.remote.c create oval 133 276 162 307 -outline {red} -tag button6 -fill {blue}
-.remote.c create oval 171 276 200 307 -outline {red} -tag button7 -fill {blue}
-
-.remote.c create rectangle 33 32 187 253 -outline black -tag screen
-.remote.c create rectangle 33 200 61 225 -outline black -tag screen
-.remote.c create rectangle 33 225 61 253 -outline black -tag screen
-.remote.c create rectangle 160 200 187 225 -outline black -tag screen
-.remote.c create rectangle 160 225 187 253 -outline black -tag screen
-.remote.c create rectangle 62 200 159 253 -outline black -tag screen
-
-set buttons(1) 0
-
-proc holdbutton {button} {
-	global buttons
-	if {$button==1} {
-		set buttons($button) [after 1000 \"continuebutton $button\"]
-	} else {
-		pushbutton $button
-		set buttons($button) [after 250 \"holdbutton $button\"]
-	}
-}
-
-proc continuebutton {button} {
-	global buttons
-	if {$button==1} {
-		pushbutton 0
-	}
-	set buttons($button) \"\"
-}
-
-proc releasebutton {button} {
-	global buttons
-	if {$buttons($button)!=\"\"} {
-		if {$button==1} {
-			pushbutton 1
-		}
-		after cancel $buttons($button)
-		set buttons($button) \"\"
-	}
-}
-
-.remote.c bind button1 <ButtonPress-1> {.remote.c itemconfigure button1 -fill green; update; holdbutton 1}
-.remote.c bind button1 <ButtonRelease-1> {.remote.c itemconfigure button1 -fill blue; releasebutton 1}
-
-.remote.c bind button2 <ButtonPress-1> {.remote.c itemconfigure button2 -fill green; update; holdbutton 2}
-.remote.c bind button2 <ButtonRelease-1> {.remote.c itemconfigure button2 -fill blue; releasebutton 2}
-
-.remote.c bind button3 <ButtonPress-1> {.remote.c itemconfigure button3 -fill green; update; holdbutton 3}
-.remote.c bind button3 <ButtonRelease-1> {.remote.c itemconfigure button3 -fill blue; releasebutton 3}
-
-.remote.c bind button4 <ButtonPress-1> {.remote.c itemconfigure button4 -fill green; update; holdbutton 4}
-.remote.c bind button4 <ButtonRelease-1> {.remote.c itemconfigure button4 -fill blue; releasebutton 4}
-
-.remote.c bind button5 <ButtonPress-1> {.remote.c itemconfigure button5 -fill green; update; holdbutton 5}
-.remote.c bind button5 <ButtonRelease-1> {.remote.c itemconfigure button5 -fill blue; releasebutton 5}
-
-.remote.c bind button6 <ButtonPress-1> {.remote.c itemconfigure button6 -fill green; update; holdbutton 6}
-.remote.c bind button6 <ButtonRelease-1> {.remote.c itemconfigure button6 -fill blue; releasebutton 6}
-
-.remote.c bind button7 <ButtonPress-1> {.remote.c itemconfigure button7 -fill green; update; holdbutton 7}
-.remote.c bind button7 <ButtonRelease-1> {.remote.c itemconfigure button7 -fill blue; releasebutton 7}
-
-catch {
-	.remote.c create image 0 282 -image B1 -anchor nw -tag downbutton1
-	.remote.c create image 22 274 -image B2 -anchor nw -tag downbutton2
-	.remote.c create image 60 275 -image B3 -anchor nw -tag downbutton3
-	.remote.c create image 93 278 -image B4 -anchor nw -tag downbutton4
-	.remote.c create image 95 298 -image B5 -anchor nw -tag downbutton5
-	.remote.c create image 131 275 -image B6 -anchor nw -tag downbutton6
-	.remote.c create image 169 274 -image B7 -anchor nw -tag downbutton7
-
-	.remote.c create image 0 0 -image Case -anchor nw
-
-	.remote.c bind button1 <ButtonPress-1> {.remote.c raise downbutton1; update; holdbutton 1}
-	.remote.c bind button1 <ButtonRelease-1> {.remote.c lower downbutton1; releasebutton 1}
-
-	.remote.c bind button2 <ButtonPress-1> {.remote.c raise downbutton2; update; holdbutton 2}
-	.remote.c bind button2 <ButtonRelease-1> {.remote.c lower downbutton2; releasebutton 2}
-
-	.remote.c bind button3 <ButtonPress-1> {.remote.c raise downbutton3; update; holdbutton 3}
-	.remote.c bind button3 <ButtonRelease-1> {.remote.c lower downbutton3; releasebutton 3}
-
-	.remote.c bind button4 <ButtonPress-1> {.remote.c raise downbutton4; update; holdbutton 4}
-	.remote.c bind button4 <ButtonRelease-1> {.remote.c lower downbutton4; releasebutton 4}
-
-	.remote.c bind button5 <ButtonPress-1> {.remote.c raise downbutton5; update; holdbutton 5}
-	.remote.c bind button5 <ButtonRelease-1> {.remote.c lower downbutton5; releasebutton 5}
-
-	.remote.c bind button6 <ButtonPress-1> {.remote.c raise downbutton6; update; holdbutton 6}
-	.remote.c bind button6 <ButtonRelease-1> {.remote.c lower downbutton6; releasebutton 6}
-
-	.remote.c bind button7 <ButtonPress-1> {.remote.c raise downbutton7; update; holdbutton 7}
-	.remote.c bind button7 <ButtonRelease-1> {.remote.c lower downbutton7; releasebutton 7}
-	
-	
-	.remote.c itemconfigure button1 -outline {} -fill {}
-	.remote.c raise button1
-	.remote.c itemconfigure button2 -outline {} -fill {}
-	.remote.c raise button2
-	.remote.c itemconfigure button3 -outline {} -fill {}
-	.remote.c raise button3
-	.remote.c itemconfigure button4 -outline {} -fill {}
-	.remote.c raise button4
-	.remote.c itemconfigure button5 -outline {} -fill {}
-	.remote.c raise button5
-	.remote.c itemconfigure button6 -outline {} -fill {}
-	.remote.c raise button6
-	.remote.c itemconfigure button7 -outline {} -fill {}
-	.remote.c raise button7
-	.remote.c itemconfigure screen -outline {} -fill {}
-	.remote.c raise screen
-}
-
-pack .remote.c -side top
-
-.remote.c bind screen <ButtonPress-1> {pen %x %y 1}
-.remote.c bind screen <B1-Motion> {pen %x %y 1}
-.remote.c bind screen <ButtonRelease-1> {pen %x %y 0}
-
-global KeyQueue
-global KeyQueueId
-global KeyQueueDelay
-set KeyQueue {}
-set KeyQueueId {}
-set KeyQueueDelay 50
-
-proc readyqueue {} {
-    global KeyQueueId
-    global KeyQueueDelay
-    if {$KeyQueueId == {}} {
-	after $KeyQueueDelay { set KeyQueueId [ after idle {sendqueue} ] }
-    }
-}
-
-proc queuekey {c} {
-    global KeyQueue
-    append KeyQueue $c
-    readyqueue
-}
-
-proc sendqueue {} {
-    global KeyQueue
-    global KeyQueueId
-    if {[string length $KeyQueue] > 0} {
-	key [string index $KeyQueue 0]
-	set KeyQueue [string range $KeyQueue 1 end]
-    }
-    set KeyQueueId {}
-    if {[string length $KeyQueue] > 0} { readyqueue }
-}
-
-bind .remote <KeyPress> {queuekey %A}
-
-## Handle pasting
-proc do_paste { } {
-    if [catch {selection get} sel] {
-	if [catch {selection get -selection CLIPBOARD} sel] {
-	    return
-	}
-    }
-    queuekey $sel
-}
-bind .remote <ButtonPress-2> {do_paste}
-
-#####  /*** Generate remote console window ***/
-
-toplevel .console
-wm title .console \"Palm Remote Console\"
-scrollbar .console.y -orient vertical -command {.console.t yview}
-text .console.t -yscrollcommand {.console.y set}
-pack .console.t -fill both -expand yes -side left
-pack .console.y -fill y -side right
-focus .console.t
-
-####  /*** Generate pilot state window ***/
-
-toplevel .state
-wm title .state {Palm State}
-label .state.l1 -text {Active mode:}
-label .state.l1x -text {Battery:}
-label .state.l2 -text {Exception:}
-label .state.l25 -text {Reset:}
-label .state.l3 -text {Function:}
-label .state.l4 -text {F-start:}
-label .state.l5 -text {F-end:}
-label .state.l6 -text {D0:}
-label .state.l7 -text {A0:}
-label .state.l8 -text {D1:}
-label .state.l9 -text {A1:}
-label .state.l10 -text {D2:}
-label .state.l11 -text {A2:}
-label .state.l12 -text {D3:}
-label .state.l13 -text {A3:}
-label .state.l14 -text {D4:}
-label .state.l15 -text {A4:}
-label .state.l16 -text {D5:}
-label .state.l17 -text {A5:}
-label .state.l18 -text {D6:}
-label .state.l19 -text {A6:}
-label .state.l20 -text {D7:}
-
-label .state.l21 -text {PC:}
-label .state.l22 -text {SR:}
-label .state.l23 -text {USP:}
-label .state.l24 -text {SSP:}
-
-label .state.halted -text {None}
-label .state.battery -text {Unknown}
-label .state.exception -text {0}
-label .state.reset -text {No}
-label .state.funcname -text {}
-label .state.funcstart -text {00000000}
-label .state.funcend -text {00000000}
-label .state.d0 -text {00000000}
-label .state.a0 -text {00000000}
-label .state.d1 -text {00000000}
-label .state.a1 -text {00000000}
-label .state.d2 -text {00000000}
-label .state.a2 -text {00000000}
-label .state.d3 -text {00000000}
-label .state.a3 -text {00000000}
-label .state.d4 -text {00000000}
-label .state.a4 -text {00000000}
-label .state.d5 -text {00000000}
-label .state.a5 -text {00000000}
-label .state.d6 -text {00000000}
-label .state.a6 -text {00000000}
-label .state.d7 -text {00000000}
-label .state.pc -text {00000000}
-label .state.sr -text {0000}
-label .state.usp -text {00000000}
-label .state.ssp -text {00000000}
-
-grid .state.l1 -column 0 -row 0 -sticky e -columnspan 2
-grid .state.halted -column 2 -row 0 -sticky w -columnspan 2
-
-grid .state.l1x -column 0 -row 1 -sticky e -columnspan 2
-grid .state.battery -column 2 -row 1 -sticky w -columnspan 2
-
-grid .state.l2 -column 0 -row 2 -sticky e -columnspan 2
-grid .state.exception -column 2 -row 2 -sticky w -columnspan 2
-
-grid .state.l25 -column 0 -row 3 -sticky e -columnspan 2
-grid .state.reset -column 2 -row 3 -sticky w -columnspan 2
-
-grid .state.l3 -column 0 -row 4 -sticky e -columnspan 2 
-grid .state.funcname -column 2 -row 4 -sticky w -columnspan 2
-
-grid .state.l4 -column 0 -row 5 -sticky e -columnspan 2 
-grid .state.funcstart -column 2 -row 5 -sticky w -columnspan 2
-
-grid .state.l5 -column 0 -row 6 -sticky e -columnspan 2 
-grid .state.funcend -column 2 -row 6 -sticky w -columnspan 2
-
-frame .state.rule1 -relief raised -bd 2 -height 4
-grid .state.rule1 -column 0 -row 7 -columnspan 4 -sticky ew
-
-grid .state.l6 -column 0 -row 8 -sticky e 
-grid .state.d0 -column 1 -row 8 -sticky w
-grid .state.l7 -column 2 -row 8 -sticky e 
-grid .state.a0 -column 3 -row 8 -sticky w
-
-grid .state.l8 -column 0 -row 9 -sticky e 
-grid .state.d1 -column 1 -row 9 -sticky w
-grid .state.l9 -column 2 -row 9 -sticky e 
-grid .state.a1 -column 3 -row 9 -sticky w
-
-grid .state.l10 -column 0 -row 10 -sticky e 
-grid .state.d2 -column 1 -row 10 -sticky w
-grid .state.l11 -column 2 -row 10 -sticky e 
-grid .state.a2 -column 3 -row 10 -sticky w
-
-grid .state.l12 -column 0 -row 11 -sticky e 
-grid .state.d3 -column 1 -row 11 -sticky w
-grid .state.l13 -column 2 -row 11 -sticky e 
-grid .state.a3 -column 3 -row 11 -sticky w
-
-grid .state.l14 -column 0 -row 12 -sticky e 
-grid .state.d4 -column 1 -row 12 -sticky w
-grid .state.l15 -column 2 -row 12 -sticky e 
-grid .state.a4 -column 3 -row 12 -sticky w
-
-grid .state.l16 -column 0 -row 13 -sticky e 
-grid .state.d5 -column 1 -row 13 -sticky w
-grid .state.l17 -column 2 -row 13 -sticky e 
-grid .state.a5 -column 3 -row 13 -sticky w
-
-grid .state.l18 -column 0 -row 14 -sticky e 
-grid .state.d6 -column 1 -row 14 -sticky w
-grid .state.l19 -column 2 -row 14 -sticky e 
-grid .state.a6 -column 3 -row 14 -sticky w
-
-grid .state.l20 -column 0 -row 15 -sticky e 
-grid .state.d7 -column 1 -row 15 -sticky w
-
-grid .state.l21 -column 0 -row 16 -sticky e 
-grid .state.pc -column 1 -row 16 -sticky w
-grid .state.l22 -column 2 -row 16 -sticky e 
-grid .state.sr -column 3 -row 16 -sticky w
-
-grid .state.l23 -column 0 -row 17 -sticky e 
-grid .state.usp -column 1 -row 17 -sticky w
-grid .state.l24 -column 2 -row 17 -sticky e 
-grid .state.ssp -column 3 -row 17 -sticky w
-
-label .state.bl2 -text {B1:}
-label .state.bl4 -text {B2:}
-label .state.bl6 -text {B3:}
-label .state.bl8 -text {B4:}
-label .state.bl10 -text {B5:}
-label .state.bl12 -text {B6:}
-
-label .state.b1 -text {00000000}
-label .state.b1a -text {Off}
-label .state.b2 -text {00000000}
-label .state.b2a -text {Off}
-label .state.b3 -text {00000000}
-label .state.b3a -text {Off}
-label .state.b4 -text {00000000}
-label .state.b4a  -text {Off}
-label .state.b5 -text {00000000}
-label .state.b5a -text {Off}
-label .state.b6 -text {00000000}
-label .state.b6a -text {Off}
-
-frame .state.rule2 -relief raised -bd 2 -height 4
-grid .state.rule2 -column 0 -row 18 -columnspan 4 -sticky ew
-
-grid .state.bl2 -column 0 -row 19 -sticky e
-grid .state.b1 -column 1 -row 19 -sticky w
-grid .state.b1a -column 2 -row 19 -sticky w 
-
-grid .state.bl4 -column 0 -row 20 -sticky e
-grid .state.b2 -column 1 -row 20 -sticky w
-grid .state.b2a -column 2 -row 20 -sticky w 
-
-grid .state.bl6 -column 0 -row 21 -sticky e
-grid .state.b3 -column 1 -row 21 -sticky w
-grid .state.b3a -column 2 -row 21 -sticky w 
-
-grid .state.bl8 -column 0 -row 22 -sticky e
-grid .state.b4 -column 1 -row 22 -sticky w
-grid .state.b4a -column 2 -row 22 -sticky w 
-
-grid .state.bl10 -column 0 -row 23 -sticky e
-grid .state.b5 -column 1 -row 23 -sticky w
-grid .state.b5a -column 2 -row 23 -sticky w 
-
-grid .state.bl12 -column 0 -row 24 -sticky e
-grid .state.b6 -column 1 -row 24 -sticky w
-grid .state.b6a -column 2 -row 24 -sticky w 
-
-###  /*** Generate debugger console window ***/
-
-wm title . \"Palm Debugger Console\"
-catch {
-	wm iconbitmap . {@pix/case.xbm}
-	wm iconbitmap .remote {@pix/case.xbm}
-	wm iconbitmap .console {@pix/case.xbm}
-	wm iconbitmap .state {@pix/case.xbm}
-	#wm iconmask . {@pix/casemask.xbm}
-}
-
-frame .m -relief raised
-frame .f
-scrollbar .f.y -orient vertical -command {.f.t yview}
-text .f.t -yscrollcommand {.f.y set} -wrap word
-pack .f.t -fill both -expand yes -side left
-pack .f.y -fill y -side right
-pack [menubutton .m.file -text {File} -menu .m.file.m] -side left
-#pack [menubutton .m.edit -text {Edit} -menu .m.edit.m] -side left
-pack [menubutton .m.windows -text {Windows} -menu .m.windows.m] -side left
-#pack [menubutton .m.help -text {display_help} -menu .m.help.m] -side right
-
-menu .m.file.m
-menu .m.windows.m
-#menu .m.edit.m
-#menu .m.help.m
-
-#wm iconify .remote
-#wm iconify .console
-#wm iconify .state
-
-
-proc ShowWindow {name1 name2 op} {
-  global show
-  if {$show($name2)} {
-    if {[wm state $name2] != \"normal\"} {
-      wm deiconify $name2
-    }
-  } else {
-    if {[wm state $name2] == \"normal\"} {
-      wm withdraw $name2
-    }
-  }
-}
-
-
-trace variable show w {ShowWindow}
-
-bind .remote <Unmap> { set show(.remote) 0 }
-bind .console <Unmap> { set show(.console) 0 }
-bind .state <Unmap> { set show(.state) 0 }
-
-bind .remote <Map> { set show(.remote) 1 }
-bind .console <Map> { set show(.console) 1 }
-bind .state <Map> { set show(.state) 1 }
-
-wm protocol .remote WM_DELETE_WINDOW { set show(.remote) 0 }
-wm protocol .console WM_DELETE_WINDOW { set show(.console) 0 }
-wm protocol .state WM_DELETE_WINDOW { set show(.state) 0 }
-
-set show(.remote) 0
-set show(.console) 0
-set show(.state) 0
-
-
-.m.file.m add command -label {Exit} -command {exit}
-
-.m.windows.m add checkbutton -label {Remote UI} -var show(.remote)
-.m.windows.m add checkbutton -label {Remote Console} -var show(.console)
-.m.windows.m add checkbutton -label {Remote State} -var show(.state)
-
-pack .m -side top -fill x
-pack .f -side top -fill both -expand yes
-focus .f.t
-
-###  /*** Configure console bindings ***/
-
-bind .console.t <Shift-KeyPress-Return> {tkTextInsert .console.t \"\\n\" ; break}
-bind .f.t <Shift-KeyPress-Return> {tkTextInsert .f.t \"\\n\" ; break}
-
-bind .console.t <Control-KeyPress-Return> {tkTextInsert .console.t \"\\n\" ; break}
-bind .f.t <Control-KeyPress-Return> {tkTextInsert .f.t \"\\n\" ; break}
-
-bind .console.t <KeyPress-Return> {Console [.console.t get {insert linestart} {insert lineend}] ; break}
-bind .f.t <KeyPress-Return> {
-	set line [.f.t get {insert linestart} {insert lineend}]
-	set f [string first \">\" $line]
-	incr f
-	set line [string range $line $f end]
-	.f.t mark set insert {insert lineend}
-	.f.t insert insert \\n
-	Debugger $line
-	if {[.f.t compare insert != {insert linestart}]} {
-		.f.t insert insert \"\\n\"
-	}
-	.f.t insert insert \"pilot-debug> \"
-	.f.t see insert
-	break
-}
-
-proc Console {cmd} {
-	.console.t mark set insert {insert lineend}
-	tkTextInsert .console.t \\n
-	transmit $cmd
-}
-
-proc Debugger {cmd} {
-	#.f.t mark set insert {insert lineend}
-	#tkTextInsert .f.t \\n
-	if {[string length [string trim $cmd]]!=0} {
-		set code [catch {eval $cmd} message]
-		if {[string length $message]} {
-			set message [string trimright $message]
-			Say \"$message\\n\"
-			#if {[.f.t compare insert != {insert linestart}]} {
-			#	Say \"\\\n\"
-			#}
-		}
-	}
-}
-
-proc Say {text} {
-	global Interactive
-	if {$Interactive} {
-	  .f.t insert insert \"$text\"
-	  .f.t see insert
-	} else {
-	  upvar result result
-	  set result \"$result$text\"
-	}
-}
-
-", NULL);
+  Tcl_VarEval(interp,
+"\n"
+"###  /*** Generate remote UI window ***/\n"
+"\n"
+"set tkdbg 1\n"
+"\n"
+"toplevel .remote\n"
+"wm title .remote {Palm Remote UI}\n"
+"\n"
+"catch {\n"
+"	if {[file exists {tools/pix/case.gif}]} {\n"
+"		set dir {tools}\n"
+"	} elseif {[file exists {",LIBDIR,"/pix/case.gif}]} {\n"
+"		set dir {",LIBDIR,"/pix}\n"
+"	} else {\n"
+"		error {No pix}\n"
+"	}\n"
+"	image create photo Case -format gif -file \"$dir/pix/case.gif\"\n"
+"	image create photo B1 -format gif -file \"$dir/pix/b1.gif\"\n"
+"	image create photo B2 -format gif -file \"$dir/pix/b2.gif\"\n"
+"	image create photo B3 -format gif -file \"$dir/pix/b3.gif\"\n"
+"	image create photo B4 -format gif -file \"$dir/pix/b4.gif\"\n"
+"	image create photo B5 -format gif -file \"$dir/pix/b5.gif\"\n"
+"	image create photo B6 -format gif -file \"$dir/pix/b6.gif\"\n"
+"	image create photo B7 -format gif -file \"$dir/pix/b7.gif\"\n"
+"}\n"
+"\n"
+"canvas .remote.c -width 221 -height 337\n"
+"\n"
+".remote.c create rectangle 27 29 196 260 -outline {red} -tag screen -fill {blue}\n"
+".remote.c create rectangle 0 280 18 306 -outline {red} -tag button1 -fill {blue}\n"
+".remote.c create oval 23 276 52 307 -outline {red} -tag button2 -fill {blue}\n"
+".remote.c create oval 63 276 92 307 -outline {red} -tag button3 -fill {blue}\n"
+".remote.c create rectangle 97 277 127 294 -outline {red} -tag button4 -fill {blue}\n"
+".remote.c create rectangle 97 300 127 317 -outline {red} -tag button5 -fill {blue}\n"
+".remote.c create oval 133 276 162 307 -outline {red} -tag button6 -fill {blue}\n"
+".remote.c create oval 171 276 200 307 -outline {red} -tag button7 -fill {blue}\n"
+"\n"
+".remote.c create rectangle 33 32 187 253 -outline black -tag screen\n"
+".remote.c create rectangle 33 200 61 225 -outline black -tag screen\n"
+".remote.c create rectangle 33 225 61 253 -outline black -tag screen\n"
+".remote.c create rectangle 160 200 187 225 -outline black -tag screen\n"
+".remote.c create rectangle 160 225 187 253 -outline black -tag screen\n"
+".remote.c create rectangle 62 200 159 253 -outline black -tag screen\n"
+"\n"
+"set buttons(1) 0\n"
+"\n"
+"proc holdbutton {button} {\n"
+"	global buttons\n"
+"	if {$button==1} {\n"
+"		set buttons($button) [after 1000 \"continuebutton $button\"]\n"
+"	} else {\n"
+"		pushbutton $button\n"
+"		set buttons($button) [after 250 \"holdbutton $button\"]\n"
+"	}\n"
+"}\n"
+"\n"
+"proc continuebutton {button} {\n"
+"	global buttons\n"
+"	if {$button==1} {\n"
+"		pushbutton 0\n"
+"	}\n"
+"	set buttons($button) \"\"\n"
+"}\n"
+"\n"
+"proc releasebutton {button} {\n"
+"	global buttons\n"
+"	if {$buttons($button)!=\"\"} {\n"
+"		if {$button==1} {\n"
+"			pushbutton 1\n"
+"		}\n"
+"		after cancel $buttons($button)\n"
+"		set buttons($button) \"\"\n"
+"	}\n"
+"}\n"
+"\n"
+".remote.c bind button1 <ButtonPress-1> {.remote.c itemconfigure button1 -fill green; update; holdbutton 1}\n"
+".remote.c bind button1 <ButtonRelease-1> {.remote.c itemconfigure button1 -fill blue; releasebutton 1}\n"
+"\n"
+".remote.c bind button2 <ButtonPress-1> {.remote.c itemconfigure button2 -fill green; update; holdbutton 2}\n"
+".remote.c bind button2 <ButtonRelease-1> {.remote.c itemconfigure button2 -fill blue; releasebutton 2}\n"
+"\n"
+".remote.c bind button3 <ButtonPress-1> {.remote.c itemconfigure button3 -fill green; update; holdbutton 3}\n"
+".remote.c bind button3 <ButtonRelease-1> {.remote.c itemconfigure button3 -fill blue; releasebutton 3}\n"
+"\n"
+".remote.c bind button4 <ButtonPress-1> {.remote.c itemconfigure button4 -fill green; update; holdbutton 4}\n"
+".remote.c bind button4 <ButtonRelease-1> {.remote.c itemconfigure button4 -fill blue; releasebutton 4}\n"
+"\n"
+".remote.c bind button5 <ButtonPress-1> {.remote.c itemconfigure button5 -fill green; update; holdbutton 5}\n"
+".remote.c bind button5 <ButtonRelease-1> {.remote.c itemconfigure button5 -fill blue; releasebutton 5}\n"
+"\n"
+".remote.c bind button6 <ButtonPress-1> {.remote.c itemconfigure button6 -fill green; update; holdbutton 6}\n"
+".remote.c bind button6 <ButtonRelease-1> {.remote.c itemconfigure button6 -fill blue; releasebutton 6}\n"
+"\n"
+".remote.c bind button7 <ButtonPress-1> {.remote.c itemconfigure button7 -fill green; update; holdbutton 7}\n"
+".remote.c bind button7 <ButtonRelease-1> {.remote.c itemconfigure button7 -fill blue; releasebutton 7}\n"
+"\n"
+"catch {\n"
+"	.remote.c create image 0 282 -image B1 -anchor nw -tag downbutton1\n"
+"	.remote.c create image 22 274 -image B2 -anchor nw -tag downbutton2\n"
+"	.remote.c create image 60 275 -image B3 -anchor nw -tag downbutton3\n"
+"	.remote.c create image 93 278 -image B4 -anchor nw -tag downbutton4\n"
+"	.remote.c create image 95 298 -image B5 -anchor nw -tag downbutton5\n"
+"	.remote.c create image 131 275 -image B6 -anchor nw -tag downbutton6\n"
+"	.remote.c create image 169 274 -image B7 -anchor nw -tag downbutton7\n"
+"\n"
+"	.remote.c create image 0 0 -image Case -anchor nw\n"
+"\n"
+"	.remote.c bind button1 <ButtonPress-1> {.remote.c raise downbutton1; update; holdbutton 1}\n"
+"	.remote.c bind button1 <ButtonRelease-1> {.remote.c lower downbutton1; releasebutton 1}\n"
+"\n"
+"	.remote.c bind button2 <ButtonPress-1> {.remote.c raise downbutton2; update; holdbutton 2}\n"
+"	.remote.c bind button2 <ButtonRelease-1> {.remote.c lower downbutton2; releasebutton 2}\n"
+"\n"
+"	.remote.c bind button3 <ButtonPress-1> {.remote.c raise downbutton3; update; holdbutton 3}\n"
+"	.remote.c bind button3 <ButtonRelease-1> {.remote.c lower downbutton3; releasebutton 3}\n"
+"\n"
+"	.remote.c bind button4 <ButtonPress-1> {.remote.c raise downbutton4; update; holdbutton 4}\n"
+"	.remote.c bind button4 <ButtonRelease-1> {.remote.c lower downbutton4; releasebutton 4}\n"
+"\n"
+"	.remote.c bind button5 <ButtonPress-1> {.remote.c raise downbutton5; update; holdbutton 5}\n"
+"	.remote.c bind button5 <ButtonRelease-1> {.remote.c lower downbutton5; releasebutton 5}\n"
+"\n"
+"	.remote.c bind button6 <ButtonPress-1> {.remote.c raise downbutton6; update; holdbutton 6}\n"
+"	.remote.c bind button6 <ButtonRelease-1> {.remote.c lower downbutton6; releasebutton 6}\n"
+"\n"
+"	.remote.c bind button7 <ButtonPress-1> {.remote.c raise downbutton7; update; holdbutton 7}\n"
+"	.remote.c bind button7 <ButtonRelease-1> {.remote.c lower downbutton7; releasebutton 7}\n"
+"	\n"
+"	\n"
+"	.remote.c itemconfigure button1 -outline {} -fill {}\n"
+"	.remote.c raise button1\n"
+"	.remote.c itemconfigure button2 -outline {} -fill {}\n"
+"	.remote.c raise button2\n"
+"	.remote.c itemconfigure button3 -outline {} -fill {}\n"
+"	.remote.c raise button3\n"
+"	.remote.c itemconfigure button4 -outline {} -fill {}\n"
+"	.remote.c raise button4\n"
+"	.remote.c itemconfigure button5 -outline {} -fill {}\n"
+"	.remote.c raise button5\n"
+"	.remote.c itemconfigure button6 -outline {} -fill {}\n"
+"	.remote.c raise button6\n"
+"	.remote.c itemconfigure button7 -outline {} -fill {}\n"
+"	.remote.c raise button7\n"
+"	.remote.c itemconfigure screen -outline {} -fill {}\n"
+"	.remote.c raise screen\n"
+"}\n"
+"\n"
+"pack .remote.c -side top\n"
+"\n"
+".remote.c bind screen <ButtonPress-1> {pen %x %y 1}\n"
+".remote.c bind screen <B1-Motion> {pen %x %y 1}\n"
+".remote.c bind screen <ButtonRelease-1> {pen %x %y 0}\n"
+"\n"
+"global KeyQueue\n"
+"global KeyQueueId\n"
+"global KeyQueueDelay\n"
+"set KeyQueue {}\n"
+"set KeyQueueId {}\n"
+"set KeyQueueDelay 50\n"
+"\n"
+"proc readyqueue {} {\n"
+"    global KeyQueueId\n"
+"    global KeyQueueDelay\n"
+"    if {$KeyQueueId == {}} {\n"
+"	after $KeyQueueDelay { set KeyQueueId [ after idle {sendqueue} ] }\n"
+"    }\n"
+"}\n"
+"\n"
+"proc queuekey {c} {\n"
+"    global KeyQueue\n"
+"    append KeyQueue $c\n"
+"    readyqueue\n"
+"}\n"
+"\n"
+"proc sendqueue {} {\n"
+"    global KeyQueue\n"
+"    global KeyQueueId\n"
+"    if {[string length $KeyQueue] > 0} {\n"
+"	key [string index $KeyQueue 0]\n"
+"	set KeyQueue [string range $KeyQueue 1 end]\n"
+"    }\n"
+"    set KeyQueueId {}\n"
+"    if {[string length $KeyQueue] > 0} { readyqueue }\n"
+"}\n"
+"\n"
+"bind .remote <KeyPress> {queuekey %A}\n"
+"\n"
+"## Handle pasting\n"
+"proc do_paste { } {\n"
+"    if [catch {selection get} sel] {\n"
+"	if [catch {selection get -selection CLIPBOARD} sel] {\n"
+"	    return\n"
+"	}\n"
+"    }\n"
+"    queuekey $sel\n"
+"}\n"
+"bind .remote <ButtonPress-2> {do_paste}\n"
+"\n"
+"#####  /*** Generate remote console window ***/\n"
+"\n"
+"toplevel .console\n"
+"wm title .console \"Palm Remote Console\"\n"
+"scrollbar .console.y -orient vertical -command {.console.t yview}\n"
+"text .console.t -yscrollcommand {.console.y set}\n"
+"pack .console.t -fill both -expand yes -side left\n"
+"pack .console.y -fill y -side right\n"
+"focus .console.t\n"
+"\n"
+"####  /*** Generate pilot state window ***/\n"
+"\n"
+"toplevel .state\n"
+"wm title .state {Palm State}\n"
+"label .state.l1 -text {Active mode:}\n"
+"label .state.l1x -text {Battery:}\n"
+"label .state.l2 -text {Exception:}\n"
+"label .state.l25 -text {Reset:}\n"
+"label .state.l3 -text {Function:}\n"
+"label .state.l4 -text {F-start:}\n"
+"label .state.l5 -text {F-end:}\n"
+"label .state.l6 -text {D0:}\n"
+"label .state.l7 -text {A0:}\n"
+"label .state.l8 -text {D1:}\n"
+"label .state.l9 -text {A1:}\n"
+"label .state.l10 -text {D2:}\n"
+"label .state.l11 -text {A2:}\n"
+"label .state.l12 -text {D3:}\n"
+"label .state.l13 -text {A3:}\n"
+"label .state.l14 -text {D4:}\n"
+"label .state.l15 -text {A4:}\n"
+"label .state.l16 -text {D5:}\n"
+"label .state.l17 -text {A5:}\n"
+"label .state.l18 -text {D6:}\n"
+"label .state.l19 -text {A6:}\n"
+"label .state.l20 -text {D7:}\n"
+"\n"
+"label .state.l21 -text {PC:}\n"
+"label .state.l22 -text {SR:}\n"
+"label .state.l23 -text {USP:}\n"
+"label .state.l24 -text {SSP:}\n"
+"\n"
+"label .state.halted -text {None}\n"
+"label .state.battery -text {Unknown}\n"
+"label .state.exception -text {0}\n"
+"label .state.reset -text {No}\n"
+"label .state.funcname -text {}\n"
+"label .state.funcstart -text {00000000}\n"
+"label .state.funcend -text {00000000}\n"
+"label .state.d0 -text {00000000}\n"
+"label .state.a0 -text {00000000}\n"
+"label .state.d1 -text {00000000}\n"
+"label .state.a1 -text {00000000}\n"
+"label .state.d2 -text {00000000}\n"
+"label .state.a2 -text {00000000}\n"
+"label .state.d3 -text {00000000}\n"
+"label .state.a3 -text {00000000}\n"
+"label .state.d4 -text {00000000}\n"
+"label .state.a4 -text {00000000}\n"
+"label .state.d5 -text {00000000}\n"
+"label .state.a5 -text {00000000}\n"
+"label .state.d6 -text {00000000}\n"
+"label .state.a6 -text {00000000}\n"
+"label .state.d7 -text {00000000}\n"
+"label .state.pc -text {00000000}\n"
+"label .state.sr -text {0000}\n"
+"label .state.usp -text {00000000}\n"
+"label .state.ssp -text {00000000}\n"
+"\n"
+"grid .state.l1 -column 0 -row 0 -sticky e -columnspan 2\n"
+"grid .state.halted -column 2 -row 0 -sticky w -columnspan 2\n"
+"\n"
+"grid .state.l1x -column 0 -row 1 -sticky e -columnspan 2\n"
+"grid .state.battery -column 2 -row 1 -sticky w -columnspan 2\n"
+"\n"
+"grid .state.l2 -column 0 -row 2 -sticky e -columnspan 2\n"
+"grid .state.exception -column 2 -row 2 -sticky w -columnspan 2\n"
+"\n"
+"grid .state.l25 -column 0 -row 3 -sticky e -columnspan 2\n"
+"grid .state.reset -column 2 -row 3 -sticky w -columnspan 2\n"
+"\n"
+"grid .state.l3 -column 0 -row 4 -sticky e -columnspan 2 \n"
+"grid .state.funcname -column 2 -row 4 -sticky w -columnspan 2\n"
+"\n"
+"grid .state.l4 -column 0 -row 5 -sticky e -columnspan 2 \n"
+"grid .state.funcstart -column 2 -row 5 -sticky w -columnspan 2\n"
+"\n"
+"grid .state.l5 -column 0 -row 6 -sticky e -columnspan 2 \n"
+"grid .state.funcend -column 2 -row 6 -sticky w -columnspan 2\n"
+"\n"
+"frame .state.rule1 -relief raised -bd 2 -height 4\n"
+"grid .state.rule1 -column 0 -row 7 -columnspan 4 -sticky ew\n"
+"\n"
+"grid .state.l6 -column 0 -row 8 -sticky e \n"
+"grid .state.d0 -column 1 -row 8 -sticky w\n"
+"grid .state.l7 -column 2 -row 8 -sticky e \n"
+"grid .state.a0 -column 3 -row 8 -sticky w\n"
+"\n"
+"grid .state.l8 -column 0 -row 9 -sticky e \n"
+"grid .state.d1 -column 1 -row 9 -sticky w\n"
+"grid .state.l9 -column 2 -row 9 -sticky e \n"
+"grid .state.a1 -column 3 -row 9 -sticky w\n"
+"\n"
+"grid .state.l10 -column 0 -row 10 -sticky e \n"
+"grid .state.d2 -column 1 -row 10 -sticky w\n"
+"grid .state.l11 -column 2 -row 10 -sticky e \n"
+"grid .state.a2 -column 3 -row 10 -sticky w\n"
+"\n"
+"grid .state.l12 -column 0 -row 11 -sticky e \n"
+"grid .state.d3 -column 1 -row 11 -sticky w\n"
+"grid .state.l13 -column 2 -row 11 -sticky e \n"
+"grid .state.a3 -column 3 -row 11 -sticky w\n"
+"\n"
+"grid .state.l14 -column 0 -row 12 -sticky e \n"
+"grid .state.d4 -column 1 -row 12 -sticky w\n"
+"grid .state.l15 -column 2 -row 12 -sticky e \n"
+"grid .state.a4 -column 3 -row 12 -sticky w\n"
+"\n"
+"grid .state.l16 -column 0 -row 13 -sticky e \n"
+"grid .state.d5 -column 1 -row 13 -sticky w\n"
+"grid .state.l17 -column 2 -row 13 -sticky e \n"
+"grid .state.a5 -column 3 -row 13 -sticky w\n"
+"\n"
+"grid .state.l18 -column 0 -row 14 -sticky e \n"
+"grid .state.d6 -column 1 -row 14 -sticky w\n"
+"grid .state.l19 -column 2 -row 14 -sticky e \n"
+"grid .state.a6 -column 3 -row 14 -sticky w\n"
+"\n"
+"grid .state.l20 -column 0 -row 15 -sticky e \n"
+"grid .state.d7 -column 1 -row 15 -sticky w\n"
+"\n"
+"grid .state.l21 -column 0 -row 16 -sticky e \n"
+"grid .state.pc -column 1 -row 16 -sticky w\n"
+"grid .state.l22 -column 2 -row 16 -sticky e \n"
+"grid .state.sr -column 3 -row 16 -sticky w\n"
+"\n"
+"grid .state.l23 -column 0 -row 17 -sticky e \n"
+"grid .state.usp -column 1 -row 17 -sticky w\n"
+"grid .state.l24 -column 2 -row 17 -sticky e \n"
+"grid .state.ssp -column 3 -row 17 -sticky w\n"
+"\n"
+"label .state.bl2 -text {B1:}\n"
+"label .state.bl4 -text {B2:}\n"
+"label .state.bl6 -text {B3:}\n"
+"label .state.bl8 -text {B4:}\n"
+"label .state.bl10 -text {B5:}\n"
+"label .state.bl12 -text {B6:}\n"
+"\n"
+"label .state.b1 -text {00000000}\n"
+"label .state.b1a -text {Off}\n"
+"label .state.b2 -text {00000000}\n"
+"label .state.b2a -text {Off}\n"
+"label .state.b3 -text {00000000}\n"
+"label .state.b3a -text {Off}\n"
+"label .state.b4 -text {00000000}\n"
+"label .state.b4a  -text {Off}\n"
+"label .state.b5 -text {00000000}\n"
+"label .state.b5a -text {Off}\n"
+"label .state.b6 -text {00000000}\n"
+"label .state.b6a -text {Off}\n"
+"\n"
+"frame .state.rule2 -relief raised -bd 2 -height 4\n"
+"grid .state.rule2 -column 0 -row 18 -columnspan 4 -sticky ew\n"
+"\n"
+"grid .state.bl2 -column 0 -row 19 -sticky e\n"
+"grid .state.b1 -column 1 -row 19 -sticky w\n"
+"grid .state.b1a -column 2 -row 19 -sticky w \n"
+"\n"
+"grid .state.bl4 -column 0 -row 20 -sticky e\n"
+"grid .state.b2 -column 1 -row 20 -sticky w\n"
+"grid .state.b2a -column 2 -row 20 -sticky w \n"
+"\n"
+"grid .state.bl6 -column 0 -row 21 -sticky e\n"
+"grid .state.b3 -column 1 -row 21 -sticky w\n"
+"grid .state.b3a -column 2 -row 21 -sticky w \n"
+"\n"
+"grid .state.bl8 -column 0 -row 22 -sticky e\n"
+"grid .state.b4 -column 1 -row 22 -sticky w\n"
+"grid .state.b4a -column 2 -row 22 -sticky w \n"
+"\n"
+"grid .state.bl10 -column 0 -row 23 -sticky e\n"
+"grid .state.b5 -column 1 -row 23 -sticky w\n"
+"grid .state.b5a -column 2 -row 23 -sticky w \n"
+"\n"
+"grid .state.bl12 -column 0 -row 24 -sticky e\n"
+"grid .state.b6 -column 1 -row 24 -sticky w\n"
+"grid .state.b6a -column 2 -row 24 -sticky w \n"
+"\n"
+"###  /*** Generate debugger console window ***/\n"
+"\n"
+"wm title . \"Palm Debugger Console\"\n"
+"catch {\n"
+"	wm iconbitmap . {@pix/case.xbm}\n"
+"	wm iconbitmap .remote {@pix/case.xbm}\n"
+"	wm iconbitmap .console {@pix/case.xbm}\n"
+"	wm iconbitmap .state {@pix/case.xbm}\n"
+"	#wm iconmask . {@pix/casemask.xbm}\n"
+"}\n"
+"\n"
+"frame .m -relief raised\n"
+"frame .f\n"
+"scrollbar .f.y -orient vertical -command {.f.t yview}\n"
+"text .f.t -yscrollcommand {.f.y set} -wrap word\n"
+"pack .f.t -fill both -expand yes -side left\n"
+"pack .f.y -fill y -side right\n"
+"pack [menubutton .m.file -text {File} -menu .m.file.m] -side left\n"
+"#pack [menubutton .m.edit -text {Edit} -menu .m.edit.m] -side left\n"
+"pack [menubutton .m.windows -text {Windows} -menu .m.windows.m] -side left\n"
+"#pack [menubutton .m.help -text {display_help} -menu .m.help.m] -side right\n"
+"\n"
+"menu .m.file.m\n"
+"menu .m.windows.m\n"
+"#menu .m.edit.m\n"
+"#menu .m.help.m\n"
+"\n"
+"#wm iconify .remote\n"
+"#wm iconify .console\n"
+"#wm iconify .state\n"
+"\n"
+"\n"
+"proc ShowWindow {name1 name2 op} {\n"
+"  global show\n"
+"  if {$show($name2)} {\n"
+"    if {[wm state $name2] != \"normal\"} {\n"
+"      wm deiconify $name2\n"
+"    }\n"
+"  } else {\n"
+"    if {[wm state $name2] == \"normal\"} {\n"
+"      wm withdraw $name2\n"
+"    }\n"
+"  }\n"
+"}\n"
+"\n"
+"\n"
+"trace variable show w {ShowWindow}\n"
+"\n"
+"bind .remote <Unmap> { set show(.remote) 0 }\n"
+"bind .console <Unmap> { set show(.console) 0 }\n"
+"bind .state <Unmap> { set show(.state) 0 }\n"
+"\n"
+"bind .remote <Map> { set show(.remote) 1 }\n"
+"bind .console <Map> { set show(.console) 1 }\n"
+"bind .state <Map> { set show(.state) 1 }\n"
+"\n"
+"wm protocol .remote WM_DELETE_WINDOW { set show(.remote) 0 }\n"
+"wm protocol .console WM_DELETE_WINDOW { set show(.console) 0 }\n"
+"wm protocol .state WM_DELETE_WINDOW { set show(.state) 0 }\n"
+"\n"
+"set show(.remote) 0\n"
+"set show(.console) 0\n"
+"set show(.state) 0\n"
+"\n"
+"\n"
+".m.file.m add command -label {Exit} -command {exit}\n"
+"\n"
+".m.windows.m add checkbutton -label {Remote UI} -var show(.remote)\n"
+".m.windows.m add checkbutton -label {Remote Console} -var show(.console)\n"
+".m.windows.m add checkbutton -label {Remote State} -var show(.state)\n"
+"\n"
+"pack .m -side top -fill x\n"
+"pack .f -side top -fill both -expand yes\n"
+"focus .f.t\n"
+"\n"
+"###  /*** Configure console bindings ***/\n"
+"\n"
+"bind .console.t <Shift-KeyPress-Return> {tkTextInsert .console.t \"\\n\" ; break}\n"
+"bind .f.t <Shift-KeyPress-Return> {tkTextInsert .f.t \"\\n\" ; break}\n"
+"\n"
+"bind .console.t <Control-KeyPress-Return> {tkTextInsert .console.t \"\\n\" ; break}\n"
+"bind .f.t <Control-KeyPress-Return> {tkTextInsert .f.t \"\\n\" ; break}\n"
+"\n"
+"bind .console.t <KeyPress-Return> {Console [.console.t get {insert linestart} {insert lineend}] ; break}\n"
+"bind .f.t <KeyPress-Return> {\n"
+"	set line [.f.t get {insert linestart} {insert lineend}]\n"
+"	set f [string first \">\" $line]\n"
+"	incr f\n"
+"	set line [string range $line $f end]\n"
+"	.f.t mark set insert {insert lineend}\n"
+"	.f.t insert insert \\n\n"
+"	Debugger $line\n"
+"	if {[.f.t compare insert != {insert linestart}]} {\n"
+"		.f.t insert insert \"\\n\"\n"
+"	}\n"
+"	.f.t insert insert \"pilot-debug> \"\n"
+"	.f.t see insert\n"
+"	break\n"
+"}\n"
+"\n"
+"proc Console {cmd} {\n"
+"	.console.t mark set insert {insert lineend}\n"
+"	tkTextInsert .console.t \\n\n"
+"	transmit $cmd\n"
+"}\n"
+"\n"
+"proc Debugger {cmd} {\n"
+"	#.f.t mark set insert {insert lineend}\n"
+"	#tkTextInsert .f.t \\n\n"
+"	if {[string length [string trim $cmd]]!=0} {\n"
+"		set code [catch {eval $cmd} message]\n"
+"		if {[string length $message]} {\n"
+"			set message [string trimright $message]\n"
+"			Say \"$message\\n\"\n"
+"			#if {[.f.t compare insert != {insert linestart}]} {\n"
+"			#	Say \"\\\n\"\n"
+"			#}\n"
+"		}\n"
+"	}\n"
+"}\n"
+"\n"
+"proc Say {text} {\n"
+"	global Interactive\n"
+"	if {$Interactive} {\n"
+"	  .f.t insert insert \"$text\"\n"
+"	  .f.t see insert\n"
+"	} else {\n"
+"	  upvar result result\n"
+"	  set result \"$result$text\"\n"
+"	}\n"
+"}\n\n", NULL);
   puts(interp->result);
   
   created = 1;
@@ -2080,25 +2078,24 @@
 
 static int proc_help(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
 {
-  Say("\
---- display_help ---\n\
-g [<addr>]                 Go: Resume execution (if address is supplied,
-                               will start at that point)\n\
-t <addr1> [<addr2>]      Till: Resume execution until addr1 (if addr2 is
-                               supplied, will start at that point)\n\
-coldboot                       Simulate the hard-reset (reset pin + power
-                               button press, i.e. lose all data)\n\
-warmboot                       Simulate a soft-reset (reset pin press)\n\
-pushbutton <button number>     Simulate button push\n\
-mirror [bool]                  Continually view the Palm's screen in the
-                               Remote UI window (if bool supplied, can
-                               turn on or off mirroring, otherwise
-                               toggles)\n\
-getdisplay                     Show the Palm's display in the Remote UI
-                               window\n\
-updatedisplay                  Force a mirror refresh\n\
-feature                        Get/Set/Read Palm features\n\
-");
+  Say(
+"--- display_help ---\n"
+"g [<addr>]                 Go: Resume execution (if address is supplied,\n"
+"                               will start at that point)\n"
+"t <addr1> [<addr2>]      Till: Resume execution until addr1 (if addr2 is\n"
+"                               supplied, will start at that point)\n"
+"coldboot                       Simulate the hard-reset (reset pin + power\n"
+"                               button press, i.e. lose all data)\n"
+"warmboot                       Simulate a soft-reset (reset pin press)\n"
+"pushbutton <button number>     Simulate button push\n"
+"mirror [bool]                  Continually view the Palm's screen in the\n"
+"                               Remote UI window (if bool supplied, can\n"
+"                               turn on or off mirroring, otherwise\n"
+"                               toggles)\n"
+"getdisplay                     Show the Palm's display in the Remote UI\n"
+"                               window\n"
+"updatedisplay                  Force a mirror refresh\n"
+"feature                        Get/Set/Read Palm features\n");
   return TCL_OK;
 }
 
@@ -2151,55 +2148,53 @@
     Tcl_CreateCommand(interp, cmds[i].name, cmds[i].proc, 0, NULL);
   }
 
-  Tcl_VarEval(interp,"\
-proc Say {text} {
-	global Interactive
-	if {$Interactive} {
-	  puts \"$text\"
-	} else {
-	  upvar result result
-	  set result \"$result$text\"
-	}
-}
-
-proc interactive {args} {
-	global Interactive
-	global errorInfo
-	set hold $Interactive
-	set Interactive 1
-	set code [catch $args message]
-	set Interactive $hold
-	error $message $errorInfo $code
-}
-
-proc noninteractive {args} {
-	global Interactive
-	global errorInfo
-	set hold $Interactive
-	set Interactive 0
-	set code [catch $args message]
-	set Interactive $hold
-	error $message $errorInfo $code
-}
-
-set Interactive 1
-
-proc bgerror {msg} {
-	Say $msg
-}
-
-proc checkup {} {
-	catch {noninteractive battery}
-	after 10000 checkup
-}
-
-after 1000 checkup
-
-proc checkupin {time} {
-	after $time {catch {noninteractive battery}}
-}
-
-",NULL);     
+  Tcl_VarEval(interp,
+"proc Say {text} {\n"
+"	global Interactive\n"
+"	if {$Interactive} {\n"
+"	  puts \"$text\"\n"
+"	} else {\n"
+"	  upvar result result\n"
+"	  set result \"$result$text\"\n"
+"	}\n"
+"}\n"
+"\n"
+"proc interactive {args} {\n"
+"	global Interactive\n"
+"	global errorInfo\n"
+"	set hold $Interactive\n"
+"	set Interactive 1\n"
+"	set code [catch $args message]\n"
+"	set Interactive $hold\n"
+"	error $message $errorInfo $code\n"
+"}\n"
+"\n"
+"proc noninteractive {args} {\n"
+"	global Interactive\n"
+"	global errorInfo\n"
+"	set hold $Interactive\n"
+"	set Interactive 0\n"
+"	set code [catch $args message]\n"
+"	set Interactive $hold\n"
+"	error $message $errorInfo $code\n"
+"}\n"
+"\n"
+"set Interactive 1\n"
+"\n"
+"proc bgerror {msg} {\n"
+"	Say $msg\n"
+"}\n"
+"\n"
+"proc checkup {} {\n"
+"	catch {noninteractive battery}\n"
+"	after 10000 checkup\n"
+"}\n"
+"\n"
+"after 1000 checkup\n"
+"\n"
+"proc checkupin {time} {\n"
+"	after $time {catch {noninteractive battery}}\n"
+"}\n\n", NULL);     
 
   Tcl_LinkVar(interp, "Interactive", (char*)&Interactive, TCL_LINK_INT);
 
@@ -2216,44 +2211,36 @@
        Type 'exit' to quit the application\n\n");
   
 #if 0
-  Say("\tWelcome to pilot-debug!\n\n\
-
-Please connect your Palm and start console or debugging mode.\n\n\
-
-(Console mode is a background task that can respond to a few commands,\n
-most importantly RPC which lets any function on the Palm be invoked. The\n
-Palm operates as usual while console mode is active, except that since\n
-the serial port is held open, HotSync and other applications that use\n
-the serial port will not work. Debug mode is activated on demand or when\n
-the Palm crashes. In debug mode, the CPU is halted, and no commands may\n
-be executed, except via a debugging console like this one.)\n\n\
-
-In the absence of special utilities, the console can be started by the\n
-\".2\" shortcut, and debugging via \".1\". To clear either mode,\n
-reboot via the reset button. If console mode is active, you may also\n
-reboot via the \"coldboot\" or \"warmboot\" commands.\n\n\
-
-The Remote UI window lets you manipulate the Palm if console mode is\n
-active. By clicking the mouse button on the screen or buttons, you can\n
-simulate pen taps, and if you type anything while the window has the\n
-focus, the Palm will receive the keystrokes.\n\n\
-
-The Remote Console window is specifically for the transmission and\n
-reception of console packets. Pressing Return on a line will transmit\n
-it, and any incoming packets will be displayed here in addition to the\n
-Debug Console.\n\n\ 
-
-The Remote State window shows the current Palm CPU state. It is only\n
-updated on request or when the Palm halts.\n\n\
-
-
-The Debugging Console window is the primary interface for pilot-debug.\n
-Pressing Return on a line that contains text will execute that line as\n
-a Tcl command. (Try 'expr 3+4'.) All of the usual Tcl and Tk commands\n
-are available, as well as some special-purpose ones, including 'help',\n
-'coldboot', 'warmboot', 'attach', 't', and 'g', (the last one continues\n
-after the Palm halts.)\n\n\ Execute 'help' for the list of commands\n
-currently implemented.\n\n\ "); 
+  Say("\tWelcome to pilot-debug!\n\n\n"
+"Please connect your Palm and start console or debugging mode.\n\n"
+"(Console mode is a background task that can respond to a few commands,\n"
+"most importantly RPC which lets any function on the Palm be invoked. The\n"
+"Palm operates as usual while console mode is active, except that since\n"
+"the serial port is held open, HotSync and other applications that use\n"
+"the serial port will not work. Debug mode is activated on demand or when\n"
+"the Palm crashes. In debug mode, the CPU is halted, and no commands may\n"
+"be executed, except via a debugging console like this one.)\n\n"
+"In the absence of special utilities, the console can be started by the\n"
+"\".2\" shortcut, and debugging via \".1\". To clear either mode,\n"
+"reboot via the reset button. If console mode is active, you may also\n"
+"reboot via the \"coldboot\" or \"warmboot\" commands.\n\n"
+"The Remote UI window lets you manipulate the Palm if console mode is\n"
+"active. By clicking the mouse button on the screen or buttons, you can\n"
+"simulate pen taps, and if you type anything while the window has the\n"
+"focus, the Palm will receive the keystrokes.\n\n"
+"The Remote Console window is specifically for the transmission and\n"
+"reception of console packets. Pressing Return on a line will transmit\n"
+"it, and any incoming packets will be displayed here in addition to the\n"
+"Debug Console.\n\n"
+"The Remote State window shows the current Palm CPU state. It is only\n"
+"updated on request or when the Palm halts.\n\n"
+"The Debugging Console window is the primary interface for pilot-debug.\n"
+"Pressing Return on a line that contains text will execute that line as\n"
+"a Tcl command. (Try 'expr 3+4'.) All of the usual Tcl and Tk commands\n"
+"are available, as well as some special-purpose ones, including 'help',\n"
+"'coldboot', 'warmboot', 'attach', 't', and 'g', (the last one continues\n"
+"after the Palm halts.)\n\n\ Execute 'help' for the list of commands\n"
+"currently implemented.\n\n"); 
 #endif
 
     /* Specify a user-specific startup file to invoke if the application is
@@ -2263,26 +2250,23 @@
 
     Tcl_SetVar(interp, "tcl_rcFileName", "~/.pdebugrc", TCL_GLOBAL_ONLY);
 
-    Tcl_VarEval(interp,"\
-      set tcl_prompt1 myprompt
-      proc myprompt {} {
-        puts -nonewline \"pilot-debug> \"
-      }
-      
-    ",NULL);
+    Tcl_VarEval(interp,
+"     set tcl_prompt1 myprompt\n"
+"     proc myprompt {} {\n"
+"       puts -nonewline \"pilot-debug> \"\n"
+"      }\n\n",NULL);
 
     /* Deal with command-line arguments */
 
-    Tcl_VarEval(interp,"\
-      if {$argc > 0} {
-        set p [lindex $argv 0]
-        set argv [lrange $argv 1 end]
-        port $p
-      } else {
-        Say \"As you have not entered a serial port on the command like, you might like to \
-set one with 'port /dev/something'\\n\\n\"
-      }
-    ",NULL);
+    Tcl_VarEval(interp,
+"      if {$argc > 0} {\n"
+"        set p [lindex $argv 0]\n"
+"        set argv [lrange $argv 1 end]\n"
+"        port $p\n"
+"      } else {\n"
+"        Say \"As you have not entered a serial port on the command like, you might like to "
+"set one with 'port /dev/something'\\n\\n\"\n"
+"      }\n",NULL);
         
     return TCL_OK;
 }