1
2
3
4
5
6
7
8
9
10
|
1
2
3
4
5
6
7
8
9
10
|
-
+
|
# -*- tclsh -*-
# FILE: "/home/joze/src/tclreadline/tclreadlineCompleter.tcl"
# LAST MODIFICATION: "Sun Sep 19 01:02:44 1999 (joze)"
# LAST MODIFICATION: "Sun Sep 19 22:09:08 1999 (joze)"
# (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
# $Id$
# ---
#
# tclreadline -- gnu readline for tcl
# Copyright (C) 1999 Johannes Zellner
#
|
︙ | | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
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
|
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
# TODO:
#
# - tcltest is missing
# - better completion for CompleteListFromList:
# RemoveUsedOptions ...
# - namespace eval fred {... <-- continue with a
# substitution in fred.
# - set tclreadline::pro<tab> geht *nicht*
# set ::tclreadline::pro<tab> geht
# - set tclreadline::pro<tab> doesn't work
# set ::tclreadline::pro<tab> does
#
# - TextObj ...
#
namespace eval tclreadline {
# the following three are from the icccm
# and used in complete(selection) and
# descendants.
#
variable selection-selections {
PRIMARY SECONDARY CLIPBOARD
}
variable selection-types {
ADOBE_PORTABLE_DOCUMENT_FORMAT
APPLE_PICT
BACKGROUND
BITMAP
CHARACTER_POSITION
CLASS
CLIENT_WINDOW
COLORMAP
COLUMN_NUMBER
COMPOUND_TEXT
DELETE
DRAWABLE
ENCAPSULATED_POSTSCRIPT
ENCAPSULATED_POSTSCRIPT_INTERCHANGE
FILE_NAME
FOREGROUND
HOST_NAME
INSERT_PROPERTY
INSERT_SELECTION
LENGTH
LINE_NUMBER
LIST_LENGTH
MODULE
MULTIPLE
NAME
ODIF
OWNER_OS
PIXMAP
POSTSCRIPT
PROCEDURE
PROCESS
STRING
TARGETS
TASK
TEXT
TIMESTAMP
USER
}
variable selection-formats {
APPLE_PICT
ATOM
ATOM_PAIR
BITMAP
COLORMAP
COMPOUND_TEXT
DRAWABLE
INTEGER
NULL
PIXEL
PIXMAP7
SPAN
STRING
TEXT
WINDOW
}
namespace export \
TryFromList CompleteFromList DisplayHints Rehash \
PreviousWord CommandCompletion RemoveUsedOptions \
HostList ChannelId InChannelId OutChannelId \
Lindex Llength CompleteBoolean WidgetChildren
|
︙ | | |
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
384
385
386
387
388
389
390
391
392
393
394
395
396
397
|
-
|
# @param cmd
# @return list of options for cmd
# @date Sep-14-1999
#
proc TrySubCmds {text cmd} {
set trystring ----
set bla 0
# try the command with and w/o trystring.
# Some commands, e.g.
# .canvas bind
# return an error if invoked w/o arguments
# but not, if invoked with arguments. Breaking
# the loop is eventually done at the end ...
|
︙ | | |
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
|
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
|
+
-
+
-
+
+
+
+
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
|
}
return [llength ${option_table}]
}
#**
# try to complete a `cmd configure|cget ..' from the command's options.
# @param text start line cmd, standard tclreadlineCompleter arguments.
# @return -- a flag indicating, if (cget|configure) was found.
# @return a tclreadline completer formatted string.
# @return resultT -- a tclreadline completer formatted string.
# @date Sep-14-1999
#
proc CompleteFromOptions {text start line} {
proc CompleteFromOptions {text start line resultT} {
upvar ${resultT} result
set result ""
# check if either `configure' or `cget' is present.
#
set lst [ProperList ${line}]
foreach keyword {configure cget} {
set idx [lsearch ${lst} ${keyword}]
if {-1 != ${idx}} {
break
}
}
if {-1 == ${idx}} {
return
return 0
}
if {[regexp {(cget|configure)$} ${line}]} {
# we are at the end of (configure|cget)
# but there's no space yet.
#
set result ${text}
return ${text}
return 1
}
# separate the command, but exclude (cget|configure)
# because cget won't return the option table. Instead
# OptionTable always uses `configure' to get the
# option table.
#
set cmd [lrange ${lst} 0 [expr ${idx} - 1]]
TraceText $cmd
TraceText ${cmd}
if {0 < [OptionTable ${cmd} options]} {
set prev [PreviousWord ${start} ${line}]
if {-1 != [set found [lsearch -exact $options(switches) ${prev}]]} {
# complete only if the user has not
# already entered something here.
#
if {![llength ${text}]} {
# check first, if the SpecificSwitchCompleter
# knows something about this switch. (note that
# `prev' contains the switch). The `0' as last
# argument makes the SpecificSwitchCompleter
# returning "" if it knows nothing specific
# about this switch.
#
set values [SpecificSwitchCompleter \
${text} ${start} ${line} ${prev} 0]
if [string length ${values}] {
set result ${values}
return 1
} else {
set val [lindex $options(value) ${found}]
if [string length ${val}] {
# return the old value only, if it's non-empty.
# use this double list to quote option
# values which have to be quoted.
#
return [list [list [lindex $options(value) ${found}]]]
}
} else {
return [CompleteFromList ${text} \
# Use this double list to quote option
# values which have to be quoted.
#
set result [list [list ${val}]]
return 1
} else {
set result ""
return 1
}
}
} else {
set result [SpecificSwitchCompleter \
${text} ${start} ${line} ${prev} 1]
return 1
}
} else {
set result [CompleteFromList ${text} \
[RemoveUsedOptions ${line} $options(switches)]]
return 1
}
}
return ""
return 1
}
proc ObjectClassCompleter {text start end line pos} {
proc ObjectClassCompleter {text start end line pos resultT} {
upvar ${resultT} result
set cmd [Lindex ${line} 0]
if {"." == [string index ${line} 0]} {
# it's a widget. Try to get it's class name.
#
if {![catch [list set class [winfo class [Lindex ${line} 0]]]]} {
if {[string length [info proc ${class}Obj]]} {
return [${class}Obj ${text} ${start} ${end} ${line} ${pos}]
set result [${class}Obj ${text} ${start} ${end} ${line} ${pos}]
return 0
}
}
}
if {![catch [list image type ${cmd}]]} {
return [ImageObj ${text} ${start} ${end} ${line} ${pos}]
}
if {![catch [list set type [image type ${cmd}]]]} {
switch -- ${type} {
photo {
set result [PhotoObj ${text} ${start} ${end} ${line} ${pos}]
return 1
}
default {
# let the fallback completers do the job.
return 0
}
}
}
return 0
}
proc CompleteFromOptionsOrSubCmds {text start end line pos} {
set from_opts [CompleteFromOptions ${text} ${start} ${line}]
if {[string length ${from_opts}]} {
if [CompleteFromOptions ${text} ${start} ${line} from_opts] {
# always return, if CompleteFromOptions returns non-zero,
# that means (configure|cget) were present. This ensures
# that TrySubCmds will not configure something by chance.
#
return ${from_opts}
} else {
# puts stderr \n\n[lrange [ProperList ${line}] 0 [expr $pos - 1]]\n
return [TrySubCmds ${text} \
[lrange [ProperList ${line}] 0 [expr $pos - 1]]]
}
return ""
|
︙ | | |
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
|
736
737
738
739
740
741
742
743
744
745
746
747
748
749
|
-
|
return ${expr_pos}
}
proc RemoveUsedOptions {line opts {terminate {}}} {
if {[llength ${terminate}]} {
if {[regexp -- ${terminate} ${line}]} {
return ""
# return ${terminate}
}
}
set new ""
foreach word ${opts} {
if {-1 == [string first ${word} ${line}]} {
lappend new ${word}
}
|
︙ | | |
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
|
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
|
-
-
-
+
+
+
-
+
-
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
# save `lindex'. works also for non-complete lines
# with opening parentheses or quotes.
# usage as `lindex'.
# Eventually returns the Rest of an incomplete line,
# if the index is `end' or == [Llength $line].
#
proc Lindex {line pos} {
if {[catch [list set sub [lindex $line $pos]]]} {
if {"end" == $pos || [Llength $line] == $pos} {
return [IncompleteListRemainder $line]
if {[catch [list set sub [lindex ${line} ${pos}]]]} {
if {"end" == ${pos} || [Llength ${line}] == ${pos}} {
return [IncompleteListRemainder ${line}]
}
set line [ProperList $line]
set line [ProperList ${line}]
# puts stderr \nproper_line=|$proper_line|
if {[catch [list set sub [lindex $line $pos]]]} { return {} }
if {[catch [list set sub [lindex ${line} ${pos}]]]} { return {} }
}
return $sub
return ${sub}
}
#**
# save `llength' (see above).
#
proc Llength {line} {
if {[catch [list set len [llength $line]]]} {
set line [ProperList $line]
if {[catch [list set len [llength $line]]]} { return {} }
if {[catch [list set len [llength ${line}]]]} {
set line [ProperList ${line}]
if {[catch [list set len [llength ${line}]]]} { return {} }
}
# puts stderr \nline=$line
return ${len}
}
#**
# save `lrange' (see above).
#
proc Lrange {line first last} {
if {[catch [list set range [lrange ${line} ${first} ${last}]]]} {
set rest [IncompleteListRemainder ${line}]
set proper [ProperList ${line}]
if {[catch [list set range [lindex ${proper} ${first} ${last}]]]} {
return {}
}
if {"end" == ${last} || [Llength ${line}] == ${last}} {
append sub " ${rest}"
}
}
return $len
return ${range}
}
#**
# Lunique -- remove duplicate entries from a sorted list
# @param list
# @return unique list
# @author Johannes Zellner
# @date Sep-19-1999
#
proc Lunique lst {
set unique ""
foreach element ${lst} {
if {${element} != [lindex ${unique} end]} {
lappend unique ${element}
}
}
return ${unique}
}
#**
# string function, which works also for older versions
# of tcl, which don't have the `end' index.
# I tried also defining `string' and thus overriding
# the builtin `string' which worked, but slowed down
|
︙ | | |
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
|
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
|
-
+
-
-
+
+
|
return [DisplayHints <$arg>]
}
}
}
# check if the command is an object of known class.
#
set res [ObjectClassCompleter $part $start $end $line $pos]
if [ObjectClassCompleter ${part} ${start} ${end} ${line} ${pos} res] {
if {[string length ${res}]} {
return ${res}
}
# Ok, also no proc. Try to do the same as for widgets now:
# try to complete from the option table if the subcommand
# is `configure' or `cget' otherwise try to get further
# subcommands.
#
return [CompleteFromOptionsOrSubCmds $part $start $end $line $pos]
return [CompleteFromOptionsOrSubCmds \
${part} ${start} ${end} ${line} ${pos}]
}
error "{NOTREACHED (this is probably an error)}"
}
# explicit command completers
#
|
︙ | | |
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
|
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
|
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
|
return [list . {}]
} else {
return [DisplayHints ${fallback}]
}
}
# TODO
proc CompleteColor text {
return [DisplayHints <color>]
proc CompleteColor {text {add ""}} {
# we set the variable only once to speed up.
#
variable colors
variable numberless_colors
if ![info exists colors] {
# from .. X11R6/lib/X11/rgb.txt
#
set colors {
snow GhostWhite WhiteSmoke gainsboro FloralWhite OldLace linen
AntiqueWhite PapayaWhip BlanchedAlmond bisque PeachPuff NavajoWhite
moccasin cornsilk ivory LemonChiffon seashell honeydew MintCream
azure AliceBlue lavender LavenderBlush MistyRose white black
DarkSlateGray DarkSlateGrey DimGray DimGrey SlateGray SlateGrey
LightSlateGray LightSlateGrey gray grey LightGrey LightGray
MidnightBlue navy NavyBlue CornflowerBlue DarkSlateBlue SlateBlue
MediumSlateBlue LightSlateBlue MediumBlue RoyalBlue blue DodgerBlue
DeepSkyBlue SkyBlue LightSkyBlue SteelBlue LightSteelBlue LightBlue
PowderBlue PaleTurquoise DarkTurquoise MediumTurquoise turquoise
cyan LightCyan CadetBlue MediumAquamarine aquamarine DarkGreen
DarkOliveGreen DarkSeaGreen SeaGreen MediumSeaGreen LightSeaGreen
PaleGreen SpringGreen LawnGreen green chartreuse MediumSpringGreen
GreenYellow LimeGreen YellowGreen ForestGreen OliveDrab DarkKhaki
khaki PaleGoldenrod LightGoldenrodYellow LightYellow yellow
gold LightGoldenrod goldenrod DarkGoldenrod RosyBrown IndianRed
SaddleBrown sienna peru burlywood beige wheat SandyBrown tan
chocolate firebrick brown DarkSalmon salmon LightSalmon orange
DarkOrange coral LightCoral tomato OrangeRed red HotPink DeepPink
pink LightPink PaleVioletRed maroon MediumVioletRed VioletRed
magenta violet plum orchid MediumOrchid DarkOrchid DarkViolet
BlueViolet purple MediumPurple thistle snow1 snow2 snow3 snow4
seashell1 seashell2 seashell3 seashell4 AntiqueWhite1 AntiqueWhite2
AntiqueWhite3 AntiqueWhite4 bisque1 bisque2 bisque3 bisque4
PeachPuff1 PeachPuff2 PeachPuff3 PeachPuff4 NavajoWhite1
NavajoWhite2 NavajoWhite3 NavajoWhite4 LemonChiffon1 LemonChiffon2
LemonChiffon3 LemonChiffon4 cornsilk1 cornsilk2 cornsilk3 cornsilk4
ivory1 ivory2 ivory3 ivory4 honeydew1 honeydew2 honeydew3 honeydew4
LavenderBlush1 LavenderBlush2 LavenderBlush3 LavenderBlush4
MistyRose1 MistyRose2 MistyRose3 MistyRose4 azure1 azure2 azure3
azure4 SlateBlue1 SlateBlue2 SlateBlue3 SlateBlue4 RoyalBlue1
RoyalBlue2 RoyalBlue3 RoyalBlue4 blue1 blue2 blue3 blue4
DodgerBlue1 DodgerBlue2 DodgerBlue3 DodgerBlue4 SteelBlue1
SteelBlue2 SteelBlue3 SteelBlue4 DeepSkyBlue1 DeepSkyBlue2
DeepSkyBlue3 DeepSkyBlue4 SkyBlue1 SkyBlue2 SkyBlue3 SkyBlue4
LightSkyBlue1 LightSkyBlue2 LightSkyBlue3 LightSkyBlue4 SlateGray1
SlateGray2 SlateGray3 SlateGray4 LightSteelBlue1 LightSteelBlue2
LightSteelBlue3 LightSteelBlue4 LightBlue1 LightBlue2 LightBlue3
LightBlue4 LightCyan1 LightCyan2 LightCyan3 LightCyan4
PaleTurquoise1 PaleTurquoise2 PaleTurquoise3 PaleTurquoise4
CadetBlue1 CadetBlue2 CadetBlue3 CadetBlue4 turquoise1
turquoise2 turquoise3 turquoise4 cyan1 cyan2 cyan3 cyan4
DarkSlateGray1 DarkSlateGray2 DarkSlateGray3 DarkSlateGray4
aquamarine1 aquamarine2 aquamarine3 aquamarine4 DarkSeaGreen1
DarkSeaGreen2 DarkSeaGreen3 DarkSeaGreen4 SeaGreen1 SeaGreen2
SeaGreen3 SeaGreen4 PaleGreen1 PaleGreen2 PaleGreen3 PaleGreen4
SpringGreen1 SpringGreen2 SpringGreen3 SpringGreen4 green1 green2
green3 green4 chartreuse1 chartreuse2 chartreuse3 chartreuse4
OliveDrab1 OliveDrab2 OliveDrab3 OliveDrab4 DarkOliveGreen1
DarkOliveGreen2 DarkOliveGreen3 DarkOliveGreen4 khaki1 khaki2
khaki3 khaki4 LightGoldenrod1 LightGoldenrod2 LightGoldenrod3
LightGoldenrod4 LightYellow1 LightYellow2 LightYellow3 LightYellow4
yellow1 yellow2 yellow3 yellow4 gold1 gold2 gold3 gold4 goldenrod1
goldenrod2 goldenrod3 goldenrod4 DarkGoldenrod1 DarkGoldenrod2
DarkGoldenrod3 DarkGoldenrod4 RosyBrown1 RosyBrown2 RosyBrown3
RosyBrown4 IndianRed1 IndianRed2 IndianRed3 IndianRed4 sienna1
sienna2 sienna3 sienna4 burlywood1 burlywood2 burlywood3 burlywood4
wheat1 wheat2 wheat3 wheat4 tan1 tan2 tan3 tan4 chocolate1
chocolate2 chocolate3 chocolate4 firebrick1 firebrick2 firebrick3
firebrick4 brown1 brown2 brown3 brown4 salmon1 salmon2 salmon3
salmon4 LightSalmon1 LightSalmon2 LightSalmon3 LightSalmon4 orange1
orange2 orange3 orange4 DarkOrange1 DarkOrange2 DarkOrange3
DarkOrange4 coral1 coral2 coral3 coral4 tomato1 tomato2 tomato3
tomato4 OrangeRed1 OrangeRed2 OrangeRed3 OrangeRed4 red1 red2
red3 red4 DeepPink1 DeepPink2 DeepPink3 DeepPink4 HotPink1
HotPink2 HotPink3 HotPink4 pink1 pink2 pink3 pink4 LightPink1
LightPink2 LightPink3 LightPink4 PaleVioletRed1 PaleVioletRed2
PaleVioletRed3 PaleVioletRed4 maroon1 maroon2 maroon3 maroon4
VioletRed1 VioletRed2 VioletRed3 VioletRed4 magenta1 magenta2
magenta3 magenta4 orchid1 orchid2 orchid3 orchid4 plum1 plum2
plum3 plum4 MediumOrchid1 MediumOrchid2 MediumOrchid3
MediumOrchid4 DarkOrchid1 DarkOrchid2 DarkOrchid3 DarkOrchid4
purple1 purple2 purple3 purple4 MediumPurple1 MediumPurple2
MediumPurple3 MediumPurple4 thistle1 thistle2 thistle3 thistle4
gray0 grey0 gray1 grey1 gray2 grey2 gray3 grey3 gray4 grey4 gray5
grey5 gray6 grey6 gray7 grey7 gray8 grey8 gray9 grey9 gray10 grey10
gray11 grey11 gray12 grey12 gray13 grey13 gray14 grey14 gray15
grey15 gray16 grey16 gray17 grey17 gray18 grey18 gray19 grey19
gray20 grey20 gray21 grey21 gray22 grey22 gray23 grey23 gray24
grey24 gray25 grey25 gray26 grey26 gray27 grey27 gray28 grey28
gray29 grey29 gray30 grey30 gray31 grey31 gray32 grey32 gray33
grey33 gray34 grey34 gray35 grey35 gray36 grey36 gray37 grey37
gray38 grey38 gray39 grey39 gray40 grey40 gray41 grey41 gray42
grey42 gray43 grey43 gray44 grey44 gray45 grey45 gray46 grey46
gray47 grey47 gray48 grey48 gray49 grey49 gray50 grey50 gray51
grey51 gray52 grey52 gray53 grey53 gray54 grey54 gray55 grey55
gray56 grey56 gray57 grey57 gray58 grey58 gray59 grey59 gray60
grey60 gray61 grey61 gray62 grey62 gray63 grey63 gray64 grey64
gray65 grey65 gray66 grey66 gray67 grey67 gray68 grey68 gray69
grey69 gray70 grey70 gray71 grey71 gray72 grey72 gray73 grey73
gray74 grey74 gray75 grey75 gray76 grey76 gray77 grey77 gray78
grey78 gray79 grey79 gray80 grey80 gray81 grey81 gray82 grey82
gray83 grey83 gray84 grey84 gray85 grey85 gray86 grey86 gray87
grey87 gray88 grey88 gray89 grey89 gray90 grey90 gray91 grey91
gray92 grey92 gray93 grey93 gray94 grey94 gray95 grey95 gray96
grey96 gray97 grey97 gray98 grey98 gray99 grey99 gray100 grey100
DarkGrey DarkGray DarkBlue DarkCyan DarkMagenta DarkRed LightGreen
}
}
if ![info exists numberless_colors] {
set numberless_colors ""
foreach color ${colors} {
regsub -all {[0-9]*} ${color} "" color
lappend numberless_colors ${color}
}
set numberless_colors [Lunique [lsort ${numberless_colors}]]
}
set matches [MatchesFromList ${text} ${numberless_colors}]
if {[llength ${matches}] < 5} {
set matches [MatchesFromList ${text} ${colors}]
if {[llength ${matches}]} {
return [CompleteFromList ${text} [concat ${colors} ${add}]]
} else {
return [CompleteFromList ${text} \
[concat ${numberless_colors} ${add}]]
}
} else {
return [CompleteFromList ${text} [concat ${numberless_colors} ${add}]]
}
}
proc CompleteCursor text {
# from <X11/cursorfont.h>
#
return [CompleteFromList ${text} {
num_glyphs x_cursor arrow based_arrow_down based_arrow_up
boat bogosity bottom_left_corner bottom_right_corner
bottom_side bottom_tee box_spiral center_ptr circle clock
coffee_mug cross cross_reverse crosshair diamond_cross dot
dotbox double_arrow draft_large draft_small draped_box
exchange fleur gobbler gumby hand1 hand2 heart icon iron_cross
left_ptr left_side left_tee leftbutton ll_angle lr_angle
man middlebutton mouse pencil pirate plus question_arrow
right_ptr right_side right_tee rightbutton rtl_logo sailboat
sb_down_arrow sb_h_double_arrow sb_left_arrow sb_right_arrow
sb_up_arrow sb_v_double_arrow shuttle sizing spider spraycan
star target tcross top_left_arrow top_left_corner
top_right_corner top_side top_tee trek ul_angle umbrella
ur_angle watch xterm
}]
}
#**
# SpecificSwitchCompleter
# ---
# @param text -- the word to complete.
# @param start -- the char index of text's start in line
# @param line -- the line gathered so far.
# @param switch -- the switch to complete for.
# @return a std tclreadline formatted completer string.
# @sa CompleteWidgetConfigurations
# @date Sep-17-1999
#
proc SpecificSwitchCompleter {text start line switch} {
# TODO:
proc SpecificSwitchCompleter {text start line switch {always 1}} {
# go to the `options' man page and look for possible values
switch -- ${switch} {
-activebackground -
-activeforeground -
-fg -
-foreground -
-bg -
|
︙ | | |
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
|
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
|
+
-
+
+
+
+
-
+
+
+
-
+
+
+
-
+
+
+
+
-
+
-
-
-
-
-
-
-
+
+
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
-
+
+
+
+
+
|
-insertborderwidth -
-insertwidth -
-selectborderwidth -
-highlightthickness -
-padx -
-pady -
-wraplength {
if ${always} {
return [DisplayHints <pixels>]
return [DisplayHints <pixels>]
} else {
return ""
}
}
-anchor {
return [CompleteFromList ${text} {
n ne e se s sw w nw center
}]
}
-bitmap { return [CompleteFromBitmaps ${text}] }
-bitmap { return [CompleteFromBitmaps ${text} ${always}] }
-cursor {
return [CompleteCursor ${text}]
-cursor { return [DisplayHints <cursor>] }
# return [DisplayHints <cursor>]
}
-exportselection -
-jump -
-setgrid -
-takefocus { return [CompleteBoolean ${text}] }
-font {
set names [font names]
if {[string length ${names}]} {
return [CompleteFromList ${text} ${names}]
} else {
if ${always} {
return [DisplayHints <font>]
return [DisplayHints <font>]
} else {
return ""
}
}
}
-image -
-selectimage {
-selectimage { return [CompleteFromImages ${text} ${always}] }
set images [image names]
if {[string length ${images}]} {
return [CompleteFromList ${text} ${images}]
} else {
return [DisplayHints <image>]
}
}
-insertofftime -
-insertontime -
-repeatdelay -
-repeatinterval {
if ${always} {
-repeatinterval { return [DisplayHints <milliSec>] }
return [DisplayHints <milliSec>]
} else {
return ""
}
}
-justify {
return [CompleteFromList ${text} {
left center right
}]
}
-orient {
return [CompleteFromList ${text} {
vertical horizontal
}]
}
-relief {
return [CompleteFromList ${text} {
raised sunken flat ridge solid groove
}]
}
-text {
if ${always} {
-text { return [DisplayHints <text>] }
return [DisplayHints <text>]
} else {
return ""
}
}
-textvariable { return [VarCompletion ${text} #0] }
-underline {
if ${always} {
-underline { return [DisplayHints <index>] }
return [DisplayHints <index>]
} else {
return ""
}
}
-xscrollcommand -
-yscrollcommand {
}
# WIDGET SPECIFIC OPTIONS
# ---
|
︙ | | |
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
|
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
|
+
-
-
+
+
+
+
+
|
}
-variable {
return [VarCompletion ${text} #0]
}
default {
# if ${always} {
set prev [PreviousWord ${start} ${line}]
return [DisplayHints <[String range ${prev} 1 end]>]
# set prev [PreviousWord ${start} ${line}]
# return [DisplayHints <[String range ${prev} 1 end]>]
#} else {
return ""
#}
}
}
}
# return [BraceOrCommand ${text} \
# ${start} ${line} ${pos} ${mod}]
#**
|
︙ | | |
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
|
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
return [PackConfig ${text} ${line} ${prev}]
}
}
}
}
return ""
}
proc PlaceConfig {text line prev} {
set opts {
-in -x -relx -y -rely -anchor -width
-relwidth -height -relheight -bordermode
}
switch -- ${prev} {
-in { return [CompleteFromList ${text} [WidgetChildren ${text}]] }
-x -
-relx -
-y -
-rely { return [DisplayHints <location>] }
-anchor { return [CompleteAnchor ${text}] }
-width -
-relwidth -
-height -
-relheight { return [DisplayHints <size>] }
-bordermode {
return [CompleteFromList ${text} {ignore inside outside}]
}
default {
return [CompleteFromList ${text} \
[RemoveUsedOptions ${line} ${opts}]]
}
}
}
proc complete(place) {text start end line pos mod} {
set sub [Lindex ${line} 1]
set prev [PreviousWord ${start} ${line}]
switch -- ${pos} {
1 {
return [CompleteFromList ${text} \
[concat [WidgetChildren ${text}] {
configure forget info slaves
}]]
}
2 {
switch -- ${sub} {
configure -
forget -
info -
slaves {
return [CompleteFromList ${text} [WidgetChildren ${text}]]
}
default {
return [PlaceConfig ${text} ${line} ${prev}]
}
}
}
default {
switch -- ${sub} {
configure {
return [PlaceConfig ${text} ${line} ${prev}]
}
forget {}
info {}
slaves {}
default {
return [PlaceConfig ${text} ${line} ${prev}]
}
}
}
}
return ""
}
proc complete(radiobutton) {text start end line pos mod} {
switch -- ${pos} {
1 { return [EventuallyInsertLeadingDot ${text} <pathName>] }
default {
return [CompleteWidgetConfigurations ${text} ${start} ${line} {
-activebackground -activeforeground -anchor -background
|
︙ | | |
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
|
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
-takefocus -troughcolor -activerelief -command
-elementborderwidth -width
}]
}
}
return ""
}
proc SelectionOpts {text start end line pos mod lst} {
set prev [PreviousWord ${start} ${line}]
if {-1 == [lsearch ${lst} ${prev}]} {
set prev "" ;# force the default arm
}
switch -- ${prev} {
-displayof {
return [CompleteFromList ${text} \
[WidgetChildren ${text}]]
}
-selection {
variable selection-selections
return [CompleteFromList ${text} ${selection-selections}]
}
-type {
variable selection-types
return [CompleteFromList ${text} ${selection-types}]
}
-command {
return [BraceOrCommand ${text} \
${start} ${end} ${line} ${pos} ${mod}]
}
-format {
variable selection-formats
return [CompleteFromList ${text} ${selection-formats}]
}
default {
return [CompleteFromList ${text} \
[RemoveUsedOptions ${line} ${lst}]]
}
}
}
proc complete(selection) {text start end line pos mod} {
switch -- ${pos} {
1 {
return [TrySubCmds ${text} [Lindex ${line} 0]]
}
default {
set sub [Lindex ${line} 1]
set widgets [WidgetChildren ${text}]
switch -- ${sub} {
clear {
return [SelectionOpts \
${text} ${start} ${end} ${line} ${pos} ${mod} {
-displayof -selection
}]
}
get {
return [SelectionOpts \
${text} ${start} ${end} ${line} ${pos} ${mod} {
-displayof -selection -type
}]
}
handle {
return [SelectionOpts \
${text} ${start} ${end} ${line} ${pos} ${mod} \
[concat {-selection -type -format} ${widgets}]]
}
own {
return [SelectionOpts \
${text} ${start} ${end} ${line} ${pos} ${mod} \
[concat {-command -selection} ${widgets}]]
}
}
}
}
}
proc complete(send) {text start end line pos mod} {
set prev [PreviousWord ${start} ${line}]
if {"-displayof" == ${prev}} {
return [TryFromList ${text} [WidgetChildren ${text}]]
}
set cmds [RemoveUsedOptions ${line} {
-async -displayof --
} {--}]
if {[llength ${cmds}]} {
return [string trim [CompleteFromList ${text} \
[concat ${cmds} <app>]]]
} else {
if {[regexp -- --$ ${line}]} {
return [list {--}]; # append a blank
} else {
# TODO make this better!
return [DisplayHints [list {<app cmd ?arg ...?>}]]
}
}
return ""
}
proc complete(text) {text start end line pos mod} {
switch -- ${pos} {
1 { return [EventuallyInsertLeadingDot ${text} <pathName>] }
default {
return [CompleteWidgetConfigurations ${text} ${start} ${line} {
-background -borderwidth -cursor -exportselection -font
-foreground -highlightbackground -highlightcolor
-highlightthickness -insertbackground -insertborderwidth
-insertofftime -insertontime -insertwidth -padx -pady
-relief -selectbackground -selectborderwidth
-selectforeground -setgrid -takefocus -xscrollcommand
-yscrollcommand -height -spacing1 -spacing2 -spacing3
-state -tabs -width -wrap
}]
}
}
return ""
}
proc complete(tk) {text start end line pos mod} {
switch -- ${pos} {
1 {
return [TrySubCmds ${text} [Lindex ${line} 0]]
}
default {
switch -- [Lindex ${line} 1] {
appname { return [DisplayHints ?newName?] }
scaling {
switch -- [PreviousWord ${start} ${line}] {
-displayof {
return [TryFromList ${text} \
[WidgetChildren ${text}]]
}
default {
return [CompleteFromList ${text} \
[RemoveUsedOptions ${line} {-displayof ?number?}]]
}
}
}
}
}
}
}
# proc complete(tk_bisque) {text start end line pos mod} {
# }
proc complete(tk_chooseColor) {text start end line pos mod} {
switch -- [PreviousWord ${start} ${line}] {
-initialcolor { return [CompleteColor ${text}] }
-parent { return [TryFromList ${text} [WidgetChildren ${text}]] }
-title { return [DisplayHints <string>] }
default {
return [TryFromList ${text} \
[RemoveUsedOptions ${line} {-initialcolor -parent -title}]]
}
}
}
proc complete(tk_dialog) {text start end line pos mod} {
switch -- ${pos} {
1 { return [CompleteFromList ${text} [ToplevelWindows]] }
2 { return [DisplayHints <title>] }
3 { return [DisplayHints <text>] }
4 { return [CompleteFromBitmaps ${text}] }
5 { return [DisplayHints <defaultIndex>] }
default { return [DisplayHints ?buttonName?] }
}
}
proc complete(tk_focusNext) {text start end line pos mod} {
switch -- ${pos} {
1 { return [CompleteFromList ${text} [WidgetChildren ${text}]] }
}
}
proc complete(tk_focusPrev) {text start end line pos mod} {
switch -- ${pos} {
1 { return [CompleteFromList ${text} [WidgetChildren ${text}]] }
}
}
# proc complete(tk_focusFollowsMouse) {text start end line pos mod} {
# }
proc GetOpenSaveFile {text start end line pos mod {add ""}} {
# enable filename completion for the first four switches.
switch -- [PreviousWord ${start} ${line}] {
-defaultextension {}
-filetypes {}
-initialdir {}
-initialfile {}
-parent {
return [CompleteFromList ${text} [WidgetChildren ${text}]]
}
-title { return [DisplayHints <titleString>] }
default {
return [CompleteFromList ${text} \
[RemoveUsedOptions ${line} [concat {
-defaultextension -filetypes -initialdir -parent -title
} ${add}]]]
}
}
}
proc complete(tk_getOpenFile) {text start end line pos mod} {
return [GetOpenSaveFile \
${text} ${start} ${end} ${line} ${pos} ${mod}]
}
proc complete(tk_getSaveFile) {text start end line pos mod} {
return [GetOpenSaveFile \
${text} ${start} ${end} ${line} ${pos} ${mod} -initialfile]
}
proc complete(tk_messageBox) {text start end line pos mod} {
switch -- [PreviousWord ${start} ${line}] {
-default {
return [CompleteFromList ${text} {
abort cancel ignore no ok retry yes
}]
}
-icon {
return [CompleteFromList ${text} {
error info question warning
}]
}
-message { return [DisplayHints <string>] }
-parent {
return [CompleteFromList ${text} [WidgetChildren ${text}]]
}
-title { return [DisplayHints <titleString>] }
-type {
return [CompleteFromList ${text} {
abortretryignore ok okcancel retrycancel yesno yesnocancel
}]
}
default {
return [CompleteFromList ${text} \
[RemoveUsedOptions ${line} {
-default -icon -message -parent -title -type
}]]
}
}
}
proc complete(tk_optionMenu) {text start end line pos mod} {
switch -- ${pos} {
1 { return [EventuallyInsertLeadingDot ${text} <pathName>] }
2 { return [VarCompletion ${text} #0] }
3 { return [DisplayHints <value>] }
default { return [DisplayHints ?value?] }
}
}
proc complete(tk_popup) {text start end line pos mod} {
switch -- ${pos} {
1 {
# display only menu widgets
#
set widgets [WidgetChildren ${text}]
set menu_widgets ""
foreach widget ${widgets} {
if {"Menu" == [winfo class ${widget}]} {
lappend menu_widgets ${widget}
}
}
if {[llength ${menu_widgets}]} {
return [TryFromList ${text} ${menu_widgets}]
} else {
return [DisplayHints <menu>]
}
}
2 { return [DisplayHints <x>] }
3 { return [DisplayHints <y>] }
4 { return [DisplayHints ?entryIndex?] }
}
}
# TODO: the name - value construct didn't work in my wish.
#
proc complete(tk_setPalette) {text start end line pos mod} {
set database {
activeBackground foreground selectColor
activeForeground highlightBackground selectBackground
background highlightColor selectForeground
disabledForeground insertBackground troughColor
}
switch -- ${pos} {
1 {
return [CompleteColor ${text} ${database}]
}
default {
switch [expr ${pos} % 2] {
1 {
return [CompleteFromList ${text} ${database}]
}
0 {
return [CompleteColor ${text}]
}
}
}
}
}
proc complete(tkwait) {text start end line pos mod} {
switch -- ${pos} {
1 {
return [CompleteFromList ${text} {
variable visibility window
}]
}
2 {
switch [Lindex ${line} 1] {
variable {
return [VarCompletion ${text} #0]
}
visibility -
window {
return [TryFromList ${text} [WidgetChildren ${text}]]
}
}
}
}
}
proc complete(toplevel) {text start end line pos mod} {
switch -- ${pos} {
1 { return [EventuallyInsertLeadingDot ${text} <pathName>] }
default {
return [CompleteWidgetConfigurations ${text} ${start} ${line} {
-borderwidth -cursor -highlightbackground -highlightcolor
-highlightthickness -relief -takefocus -background
-class -colormap -container -height -menu -screen
-use -visual -width
}]
}
}
return ""
}
proc complete(winfo) {text start end line pos mod} {
set cmd [lindex ${line} 1]
set sub [Lindex ${line} 1]
switch -- ${pos} {
1 {
return [TrySubCmds ${text} winfo]
}
2 {
switch -- ${sub} {
atom {
return [TryFromList ${text} {-displayof <name>}]
}
containing {
return [TryFromList ${text} {-displayof <rootX>}]
}
interps {
return [TryFromList ${text} -displayof]
}
atomname -
pathname {
return [TryFromList ${text} {-displayof <id>}]
}
default {
return [TryFromList ${text} [WidgetChildren ${text}]]
return [TryFromList ${text} [WidgetChildren ${text}]]
}
}
}
default {
switch -- ${sub} {
atom {
switch -- [PreviousWord ${start} ${line}] {
-displayof {
return [TryFromList ${text} \
[WidgetChildren ${text}]]
}
default { return [DisplayHints <name>] }
}
}
containing {
switch -- [Lindex ${line} 2] {
-displayof {
switch -- ${pos} {
3 {
return [TryFromList ${text} \
[WidgetChildren ${text}]]
}
4 {
return [DisplayHints <rootX>]
}
5 {
return [DisplayHints <rootY>]
}
}
}
default { return [DisplayHints <rootY>] }
}
}
interps {
switch -- [PreviousWord ${start} ${line}] {
-displayof {
return [TryFromList ${text} \
[WidgetChildren ${text}]]
}
default {}
}
}
atomname -
pathname {
switch -- [PreviousWord ${start} ${line}] {
-displayof {
return [TryFromList ${text} \
[WidgetChildren ${text}]]
}
default { return [DisplayHints <id>] }
}
}
visualsavailable { return [DisplayHints ?includeids?] }
default {
return [TryFromList ${text} [WidgetChildren ${text}]]
}
}
}
}
return ""
}
proc complete(wm) {text start end line pos mod} {
set sub [Lindex ${line} 1]
switch -- ${pos} {
1 {
return [CompleteFromList ${text} {
aspect client colormapwindows command deiconify focusmodel
frame geometry grid group iconbitmap iconify iconmask iconname
iconposition iconwindow maxsize minsize overrideredirect
positionfrom protocol resizable sizefrom state title transient
withdraw
}]
}
2 {
return [TryFromList ${text} [ToplevelWindows]]
}
3 {
switch -- ${sub} {
aspect { return [DisplayHints ?minNumer?] }
client { return [DisplayHints ?name?] }
colormapwindows {
return [CompleteListFromList ${text} \
[string trimleft [IncompleteListRemainder ${line}]] \
[WidgetChildren .] \{ { } \}]
}
command { return [DisplayHints ?value?] }
focusmodel {
return [CompleteListFromList ${text} {active passive}]
}
geometry {
return [DisplayHints ?<width>x<height>+-<x>+-<y>?]
}
grid { return [DisplayHints ?baseWidth?] }
group {
return [TryFromList ${text} [WidgetChildren ${text}]]
}
iconbitmap -
iconmask { return [CompleteFromBitmaps ${text}] }
iconname { return [DisplayHints ?newName?] }
iconposition { return [DisplayHints ?x?] }
iconwindow {
return [TryFromList ${text} [WidgetChildren ${text}]]
}
maxsize -
minsize { return [DisplayHints ?width?] }
overrideredirect { return [CompleteBoolean ${text}] }
positionfrom -
sizefrom {
return [CompleteFromList ${text} {position user}]
}
protocol {
return [CompleteFromList ${text} {
WM_TAKE_FOCUS WM_SAVE_YOURSELF WM_DELETE_WINDOW
}]
}
resizable { return [DisplayHints ?width?] }
title { return [DisplayHints ?string?] }
transient {
return [TryFromList ${text} [WidgetChildren ${text}]]
}
default {
return [TryFromList ${text} [ToplevelWindows]]
}
}
}
4 {
switch -- ${sub} {
aspect { return [DisplayHints ?minDenom?] }
grid { return [DisplayHints ?baseHeight?] }
iconposition { return [DisplayHints ?y?] }
maxsize -
minsize { return [DisplayHints ?height?] }
protocol {
return [BraceOrCommand ${text} \
${start} ${end} ${line} ${pos} ${mod}]
}
resizable { return [DisplayHints ?height?] }
}
}
5 {
switch -- ${sub} {
aspect { return [DisplayHints ?maxNumer?] }
grid { return [DisplayHints ?widthInc?] }
}
}
6 {
switch -- ${sub} {
aspect { return [DisplayHints ?maxDenom?] }
grid { return [DisplayHints ?heightInc?] }
}
}
}
return ""
}
# ==== ObjCmd completers ==========================
#
# @note when a proc is commented out, the fallback
# completers do the job rather well.
#
# =================================================
# proc ImageObj {text start end line pos} {
# set type [image type [Lindex ${line} 0]]
# switch -- ${type} {
# bitmap {}
# photo {}
# }
# return ""
# }
# proc ButtonObj {text start end line pos} {
# return ""
# }
proc CompleteFromBitmaps text {
proc CompleteFromBitmaps {text {always 1}} {
set inames [image names]
set bitmaps ""
foreach name $inames {
if {"bitmap" == [image type $name]} {
lappend bitmaps ${name}
}
}
if {[string length ${bitmaps}]} {
return [CompleteFromList \
${text} ${bitmaps}]
} else {
if ${always} {
return [DisplayHints <bitmaps>]
return [DisplayHints <bitmaps>]
} else {
return ""
}
}
}
proc CompleteFromImages {text {always 1}} {
set inames [image names]
if {[string length ${inames}]} {
return [CompleteFromList ${text} ${inames}]
} else {
if ${always} {
return [DisplayHints <image>]
} else {
return ""
}
}
}
proc CompleteAnchor text {
return [CompleteFromList ${text} {
n ne e se s sw w nw center
}]
|
︙ | | |
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
|
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
|
-
-
-
-
+
-
-
-
-
|
}]]
}
}
}
image {
switch -- ${prev} {
-anchor { return [CompleteAnchor ${text}] }
-image {
set images [image names]
if {[string length ${images}]} {
return [CompleteFromList ${text} ${images}]
-image { return [CompleteFromImages ${text}] }
} else {
return [DisplayHints <image>]
}
}
-tags { return [DisplayHints <tagList>] }
default {
return [CompleteFromList ${text} \
[RemoveUsedOptions ${line} {
-anchor -image -tags
}]]
}
|
︙ | | |
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
|
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
|
-
+
|
}
}
proc CanvasObj {text start end line pos} {
set sub [Lindex ${line} 1]
set prev [PreviousWord ${start} ${line}]
if {1 == $pos} {
return ""; # let the fallback routines do the job.
return [TrySubCmds ${text} [Lindex ${line} 0]]
}
switch -- ${sub} {
addtag {
switch -- ${pos} {
2 { return [DisplayHints <tag>] }
3 {
return [CompleteFromList ${text} {
|
︙ | | |
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
|
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
|
-
+
+
+
+
+
+
|
dtag {
switch -- ${pos} {
2 { return [DisplayHints <tagOrId>] }
3 { return [DisplayHints ?tagToDelete?] }
}
}
find {
# let the fallback routines do the job.
switch -- ${pos} {
2 {
return [TrySubCmds ${text} [Lrange ${line} 0 1]]
}
default { return [DisplayHints ?arg?] }
}
}
focus {
switch -- ${pos} {
2 { return [DisplayHints ?tagOrId?] }
}
}
gettags {
|
︙ | | |
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
|
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
|
-
+
-
-
+
+
+
|
}]
}
proc EntryObj {text start end line pos} {
set sub [Lindex ${line} 1]
set prev [PreviousWord ${start} ${line}]
if {1 == $pos} {
return ""; # let the fallback routines do the job.
return [TrySubCmds ${text} [Lindex ${line} 0]]
}
switch -- ${sub} {
bbox -
icursor -
index { return [EntryIndex ${text}] }
cget {}
configure {}
get {}
insert {
switch -- ${pos} {
2 { return [EntryIndex ${text}] }
3 { return [DisplayHints <string>] }
}
}
scan { return [WidgetScan ${text} ${pos}] }
selection {
switch -- ${pos} {
# let the fallback routines do the job.
2 { return "" }
2 {
return [TrySubCmds ${text} [Lrange ${line} 0 1]]
}
3 {
switch -- ${prev} {
adjust -
from -
to { return [EntryIndex ${text}] }
clear -
present {}
|
︙ | | |
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
|
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
|
-
+
|
# the fallback routines do the job pretty well.
# }
proc ListboxObj {text start end line pos} {
set sub [Lindex ${line} 1]
set prev [PreviousWord ${start} ${line}]
if {1 == $pos} {
return ""; # let the fallback routines do the job.
return [TrySubCmds ${text} [Lindex ${line} 0]]
}
switch -- ${sub} {
activate -
bbox -
index -
see {
switch -- ${pos} {
|
︙ | | |
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
|
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
|
-
+
-
-
-
-
-
-
-
|
if {[string length ${names}]} {
return [CompleteFromList ${text} ${names}]
} else {
return [DisplayHints <fontname>]
}
}
-image -
-selectimage {
-selectimage { return [CompleteFromImages ${text}] }
set names [image names]
if {[string length ${names}]} {
return [CompleteFromList ${text} ${names}]
} else {
return [DisplayHints <image>]
}
}
-label { return [DisplayHints <label>] }
-menu {
set names [WidgetChildren [Lindex ${line} 0]]
if {[string length ${names}]} {
return [CompleteFromList ${text} ${names}]
} else {
|
︙ | | |
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
|
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
|
-
+
|
}
}
proc MenuObj {text start end line pos} {
set sub [Lindex ${line} 1]
set prev [PreviousWord ${start} ${line}]
if {1 == $pos} {
return ""; # let the fallback routines do the job.
return [TrySubCmds ${text} [Lindex ${line} 0]]
}
switch -- ${sub} {
activate -
index -
invoke -
postcascade -
type -
|
︙ | | |
5726
5727
5728
5729
5730
5731
5732
5733
5734
|
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
3 { return [DisplayHints <y>] }
}
}
# ??? XXX
unpost {}
}
}
proc PhotoObj {text start end line pos} {
set sub [Lindex ${line} 1]
set prev [PreviousWord ${start} ${line}]
set copy_opts { -from -to -shrink -zoom -subsample }
set read_opts { -from -to -shrink -format }
set write_opts { -from -format }
switch -- ${pos} {
1 {
return [CompleteFromList ${text} {
blank cget configure copy get put read redither write
}]
}
2 {
switch -- ${sub} {
blank {}
cget {}
configure {}
redither {}
copy { return [CompleteFromImages ${text}] }
get { return [DisplayHints <x>] }
put { return [DisplayHints <data>] }
read {}
write {}
}
}
3 {
switch -- ${sub} {
blank {}
cget {}
configure {}
redither {}
copy { return [CompleteFromList ${text} ${copy_opts}] }
get { return [DisplayHints <y>] }
put { return [CompleteFromList ${text} -to] }
read { return [CompleteFromList ${text} ${read_opts}] }
write { return [CompleteFromList ${text} ${write_opts}] }
}
}
default {
switch -- ${sub} {
blank {}
cget {}
configure {}
redither {}
get {}
copy {
switch -- ${prev} {
-from -
-to { return [DisplayHints [list <x1 y1 x2 y2>]] }
-zoom -
-subsample { return [DisplayHints [list <x y>]] }
default {
return [CompleteFromList ${text} \
[RemoveUsedOptions ${line} ${copy_opts}]]
}
}
}
put {
switch -- ${prev} {
-to {
return [DisplayHints [list <x1 y1 x2 y2>]]
}
}
}
read {
switch -- ${prev} {
-from { return [DisplayHints [list <x1 y1 x2 y2>]] }
-to { return [DisplayHints [list <x y>]] }
-format { return [DisplayHints <formatName>] }
default {
return [CompleteFromList ${text} \
[RemoveUsedOptions ${line} ${read_opts}]]
}
}
}
write {
switch -- ${prev} {
-from { return [DisplayHints [list <x1 y1 x2 y2>]] }
-format { return [DisplayHints <formatName>] }
default {
return [CompleteFromList ${text} \
[RemoveUsedOptions ${line} ${write_opts}]]
}
}
}
}
}
}
}
# proc RadiobuttonObj {text start end line pos} {
# the fallback routines do the job pretty well.
# }
proc ScaleObj {text start end line pos} {
set sub [Lindex ${line} 1]
set prev [PreviousWord ${start} ${line}]
switch -- ${pos} {
1 {
return [TrySubCmds ${text} [Lindex ${line} 0]]
}
2 {
switch -- ${sub} {
coords { return [DisplayHints ?value?] }
get { return [DisplayHints ?x?] }
identify { return [DisplayHints <x>] }
set { return [DisplayHints <value>] }
}
}
3 {
switch -- ${sub} {
get { return [DisplayHints ?y?] }
identify { return [DisplayHints <y>] }
}
}
}
}
proc ScrollbarObj {text start end line pos} {
set sub [Lindex ${line} 1]
set prev [PreviousWord ${start} ${line}]
# note that the `prefix moveto|scroll'
# construct is hard to complete.
#
switch -- ${pos} {
1 {
return [TrySubCmds ${text} [Lindex ${line} 0]]
}
2 {
switch -- ${sub} {
activate {
return [CompleteFromList ${text} {
arrow1 slider arrow2
}]
}
fraction -
identify { return [DisplayHints <x>] }
delta { return [DisplayHints <deltaX>] }
set { return [DisplayHints <first>] }
}
}
3 {
switch -- ${sub} {
fraction -
identify { return [DisplayHints <y>] }
delta { return [DisplayHints <deltaY>] }
set { return [DisplayHints <last>] }
}
}
}
}
proc TextObj {text start end line pos} {
# TODO ...
return [CompleteFromOptionsOrSubCmds \
${text} ${start} ${end} ${line} ${pos}]
}
}; # namespace tclreadline
|