Check-in [f06e7a16c7]
Not logged in
Overview
SHA1:f06e7a16c7a85fcef2982390345e0670001a12ba
Date: 1999-09-19 10:48:54
User: johannes@zellner.org
Comment: share/vim/ft/tcl_ft.vim src/tclreadline/tclreadlineCompleter.tcl
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
1999-09-19
21:18
[a7cb82dbde] share/vim/functions/tcleval.vim src/tclreadline/README src/tclreadline/configure.in src/tclreadline/tclreadline.c src/tclreadline/tclreadline.n.in src/tclreadline/tclreadlineCompleter.tcl src/tclreadline/tclreadlineSetup.tcl.in (user: johannes@zellner.org, tags: trunk)
10:48
[f06e7a16c7] share/vim/ft/tcl_ft.vim src/tclreadline/tclreadlineCompleter.tcl (user: johannes@zellner.org, tags: trunk)
1999-09-18
02:31
[7e22ff2cc0] src/tclreadline/tclreadline.c src/tclreadline/tclreadlineCompleter.tcl (user: johannes@zellner.org, tags: trunk)
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Modified tclreadlineCompleter.tcl from [e0fb9f8efc] to [d353429a4a].

     1      1   # -*- tclsh -*-
     2      2   # FILE: "/home/joze/src/tclreadline/tclreadlineCompleter.tcl"
     3         -# LAST MODIFICATION: "Sat Sep 18 04:27:54 1999 (joze)"
            3  +# LAST MODIFICATION: "Sun Sep 19 01:02:44 1999 (joze)"
     4      4   # (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
     5      5   # $Id$
     6      6   # ---
     7      7   #
     8      8   # tclreadline -- gnu readline for tcl
     9      9   # Copyright (C) 1999  Johannes Zellner
    10     10   #
................................................................................
    44     44   
    45     45   namespace eval tclreadline {
    46     46   
    47     47   namespace export \
    48     48   TryFromList CompleteFromList DisplayHints Rehash \
    49     49   PreviousWord CommandCompletion RemoveUsedOptions \
    50     50   HostList ChannelId InChannelId OutChannelId \
    51         -Lindex Llength CompleteBoolean
           51  +Lindex Llength CompleteBoolean WidgetChildren
    52     52   
    53     53   # set tclreadline::trace to 1, if you
    54     54   # want to enable explicit trace calls.
    55     55   #
    56     56   variable trace
    57     57   
    58     58   # set tclreadline::trace_procs to 1, if you
................................................................................
   140    140   # a space after a complete (single) match.
   141    141   #
   142    142   proc TryFromList {text lst {allow ""} {inhibit 0}} {
   143    143   
   144    144   	# puts stderr "(CompleteFromList) \ntext=|$text|"
   145    145   	# puts stderr "(CompleteFromList) lst=|$lst|"
   146    146   	set pre [GetQuotedPrefix ${text}]
   147         -	set matches [MatchesFromList $text $lst $allow]
          147  +	set matches [MatchesFromList ${text} ${lst} ${allow}]
   148    148   
   149    149   	# puts stderr "(CompleteFromList) matches=|$matches|"
   150    150   	if {1 == [llength $matches]} { ; # unique match
   151    151   		# puts stderr \nunique=$matches\n
   152    152   		# puts stderr "\n|${pre}${matches}[Right ${pre}]|\n"
   153    153   		set null [string index $matches 0]
   154         -		if {"<" == $null || "?" == $null} {
          154  +		if {("<" == ${null} || "?" == ${null}) && \
          155  +			-1 == [string first ${null} ${allow}]
          156  +		} {
   155    157   			set completion [string trim "[list $text] $lst"]
   156    158   		} else {
   157    159   			set completion [string trim ${pre}${matches}[Right ${pre}]]
   158    160   		}
   159    161   		if {$inhibit} {
   160    162   			return [list $completion {}]
   161    163   		} else {
................................................................................
   178    180   #**
   179    181   # CompleteFromList will never return an empty string.
   180    182   # completes, if a completion can be done, or ring
   181    183   # the bell if not. If inhibit is non-zero, the result
   182    184   # will be formatted such that readline will not insert
   183    185   # a space after a complete (single) match.
   184    186   #
   185         -proc CompleteFromList {text lst {inhibit 0}} {
   186         -	set result [TryFromList ${text} ${lst} "" $inhibit]
          187  +proc CompleteFromList {text lst {allow ""} {inhibit 0}} {
          188  +	set result [TryFromList ${text} ${lst} ${allow} $inhibit]
   187    189   	if {![llength ${result}]} {
   188    190   		Alert
   189    191   		# return [string trim [list ${text}] ${lst}"]
   190    192   		if {[llength ${lst}]} {
   191    193   			return [string trim "${text} ${lst}"]
   192    194   		} else {
   193    195   			return [string trim [list ${text} {}]]
................................................................................
   391    393   		}
   392    394   		if {"" == ${str}} {
   393    395   			break
   394    396   		}
   395    397   	}
   396    398   	return ""
   397    399   }
          400  +
          401  +#**
          402  +# try to get casses for commands which
          403  +# allow `configure' (cget).
          404  +# @param  command.
          405  +# @param  optionsT where the table will be stored.
          406  +# @return number of options
          407  +# @date   Sat-Sep-18
          408  +#
          409  +proc ClassTable {cmd} {
          410  +
          411  +	# first we build an option table.
          412  +	# We always use `configure' here,
          413  +	# because cget will not return the
          414  +	# option table.
          415  +	#
          416  +	if {[catch [list set option_table [eval ${cmd} configure]] msg]} {
          417  +		return ""
          418  +	}
          419  +	set classes ""
          420  +	foreach optline ${option_table} {
          421  +		if {5 != [llength ${optline}]} continue else {
          422  +			lappend classes [lindex ${optline} 2]
          423  +		}
          424  +	}
          425  +	return ${classes}
          426  +}
   398    427   
   399    428   #**
   400    429   # try to get options for commands which
   401    430   # allow `configure' (cget).
   402    431   # @param command.
   403    432   # @param optionsT where the table will be stored.
   404    433   # @return number of options
................................................................................
   533    562   	if {![string length ${fullpart}]} {
   534    563   
   535    564   		# nothing typed so far. Insert a $pre
   536    565   		# and inhibit further completion.
   537    566   		#
   538    567   		return [list ${pre} {}]
   539    568   
   540         -	} elseif {[regexp ${post} ${text}]} {
          569  +	} elseif {${post} == [String index ${text} end]} {
   541    570   
   542    571   		# finalize, append the post and a space.
   543    572   		#
   544    573   		set diff \
   545    574   		[expr [CountChar ${fullpart} ${pre}] - [CountChar ${fullpart} ${post}]]
   546    575   		for {set i 0} {${i} < ${diff}} {incr i} {
   547    576   			append text ${post}
................................................................................
   565    594   	# TODO this is awkward. Think of making it better!
   566    595   	#
   567    596   	if {1 == [llength ${exact_matches}] && -1 != [lsearch ${lst} ${right}]
   568    597   	} {
   569    598   		#set completion [CompleteFromList ${right} [list ${sep} ${post}] 1]
   570    599   		return [list ${left}${right}${sep} {}]
   571    600   	} else {
   572         -		set completion [CompleteFromList ${right} ${lst} 1]
          601  +		set completion [CompleteFromList ${right} ${lst} "" 1]
   573    602   	}
   574    603   	# puts stderr \ncompletion=|$completion|
   575    604   	if {![string length [lindex $completion 0]]} {
   576    605   		return [concat [list ${left}] [lrange $completion 1 end]]
   577    606   	} elseif {[string length ${left}]} {
   578    607   		return [list ${left}]${completion}
   579    608   	} else {
................................................................................
   683    712   proc IsWhite {char} {
   684    713   	if {" " == $char || "\n" == $char || "\t" == $char} {
   685    714   		return 1
   686    715   	} else {
   687    716   		return 0
   688    717   	}
   689    718   }
          719  +
          720  +proc PreviousWordOfIncompletePosition {start line} {
          721  +	return [lindex [ProperList [string range ${line} 0 ${start}]] end]
          722  +}
   690    723   
   691    724   proc PreviousWord {start line} {
   692    725   	incr start -1
   693    726   	set found 0
   694    727   	for {set i $start} {$i > 0} {incr i -1} {
   695    728   		set c [string index $line $i]
   696    729   		if {${found} && [IsWhite $c]} {
................................................................................
   896    929   	# puts stderr \nline=$line
   897    930   	return $len
   898    931   }
   899    932   
   900    933   #**
   901    934   # string function, which works also for older versions
   902    935   # of tcl, which don't have the `end' index.
          936  +# I tried also defining `string' and thus overriding
          937  +# the builtin `string' which worked, but slowed down
          938  +# things considerably. So I decided to call `String'
          939  +# only if I really need the `end' index.
   903    940   #
   904    941   proc String args {
   905    942   	if {[info tclversion] < 8.2} {
   906    943   		switch [lindex $args 1] {
   907    944   			range -
   908    945   			index {
   909    946   				if {"end" == [lindex $args end]} {
................................................................................
   923    960   		return [String range $text 1 end]
   924    961   	} else {
   925    962   		return $text
   926    963   	}
   927    964   }
   928    965   
   929    966   proc VarCompletion {text {level -1}} {
   930         -	if {-1 == ${level}} {
   931         -		set level [info level]
   932         -	} else {
   933         -		incr level
          967  +	if {"#" != [string index ${level} 0]} {
          968  +		if {-1 == ${level}} {
          969  +			set level [info level]
          970  +		} else {
          971  +			incr level
          972  +		}
   934    973   	}
   935    974   	set pre [GetQuotedPrefix ${text}]
   936    975   	set var [StripPrefix ${text}]
   937    976   	# puts stderr "(VarCompletion) pre=|$pre|"
   938    977   	# puts stderr "(VarCompletion) var=|$var|"
   939    978   
   940    979   	# arrays
................................................................................
  2660   2699   
  2661   2700   proc complete(open) {text start end line pos mod} {
  2662   2701   		# 2 { return [DisplayHints ?access?] }
  2663   2702   	switch -- $pos {
  2664   2703   		2 {
  2665   2704   			set access {r r+ w w+ a a+ 
  2666   2705   				RDONLY WRONLY RDWR APPEND CREAT EXCL NOCTTY NONBLOCK TRUNC}
  2667         -			return [CompleteFromList ${text} $access]
         2706  +			return [CompleteFromList ${text} ${access}]
  2668   2707   		}
  2669   2708   		3 { return [DisplayHints ?permissions?] }
  2670   2709   	}
  2671   2710   	return ""
  2672   2711   }
  2673   2712   
  2674   2713   proc complete(package) {text start end line pos mod} {
................................................................................
  2677   2716   		1 {
  2678   2717   			set cmds {
  2679   2718   				forget ifneeded names present provide require
  2680   2719   				unknown vcompare versions vsatisfies}
  2681   2720   			return [TryFromList $text $cmds]
  2682   2721   		}
  2683   2722   		2 {
  2684         -			switch -- $cmd {
         2723  +			switch -- ${cmd} {
  2685   2724   				forget -
  2686   2725   				ifneeded -
  2687   2726   				provide -
  2688   2727   				versions { return [CompleteFromList ${mod} [package names]] }
  2689   2728   				present -
  2690   2729   				require {
  2691   2730   					return [CompleteFromList ${mod} "-exact [package names]"] }
................................................................................
  2693   2732   				unknown { return [DisplayHints ?command?] }
  2694   2733   				vcompare -
  2695   2734   				vsatisfies { return [DisplayHints <version1>] }
  2696   2735   			}
  2697   2736   		}
  2698   2737   		3 {
  2699   2738   			set versions ""
  2700         -			catch [list set versions [package versions [Lindex $line 2]]]
  2701         -			switch -- $cmd {
         2739  +			catch [list set versions [package versions [Lindex ${line} 2]]]
         2740  +			switch -- ${cmd} {
  2702   2741   				forget {}
  2703   2742   				ifneeded {
  2704   2743   					if {"" != $versions} {
  2705         -						return [CompleteFromList ${text} $versions]
         2744  +						return [CompleteFromList ${text} ${versions}]
  2706   2745   					} else {
  2707   2746   						return [DisplayHints <version>]
  2708   2747   					}
  2709   2748   				}
  2710   2749   				provide {
  2711         -					if {"" != $versions} {
  2712         -						return [CompleteFromList ${text} $versions]
         2750  +					if {"" != ${versions}} {
         2751  +						return [CompleteFromList ${text} ${versions}]
  2713   2752   					} else {
  2714   2753   						return [DisplayHints ?version?]
  2715   2754   					}
  2716   2755   				}
  2717   2756   				versions {}
  2718   2757   				present -
  2719   2758   				require {
  2720   2759   					if {"-exact" == [PreviousWord ${start} ${line}]} {
  2721   2760   						return [CompleteFromList ${mod} [package names]]
  2722   2761   					} else {
  2723         -						if {"" != $versions} {
  2724         -							return [CompleteFromList ${text} $versions]
         2762  +						if {"" != ${versions}} {
         2763  +							return [CompleteFromList ${text} ${versions}]
  2725   2764   						} else {
  2726   2765   							return [DisplayHints ?version?]
  2727   2766   						}
  2728   2767   					}
  2729   2768   				}
  2730   2769   				names {}
  2731   2770   				unknown {}
................................................................................
  2734   2773   			}
  2735   2774   		}
  2736   2775   	}
  2737   2776   	return ""
  2738   2777   }
  2739   2778   
  2740   2779   proc complete(pid) {text start end line pos mod} {
  2741         -	switch -- $pos {
         2780  +	switch -- ${pos} {
  2742   2781   		1 { return [ChannelId ${text}] }
  2743   2782   	}
  2744   2783   }
  2745   2784   
  2746   2785   proc complete(pkg_mkIndex) {text start end line pos mod} {
  2747   2786   	set cmds [RemoveUsedOptions ${line} {-direct -load -verbose -- <dir>} {--}]
  2748         -	set res [string trim [TryFromList $text $cmds]]
         2787  +	set res [string trim [TryFromList ${text} ${cmds}]]
  2749   2788   	set prev [PreviousWord ${start} ${line}]
  2750         -	if {"-load" == $prev} {
         2789  +	if {"-load" == ${prev}} {
  2751   2790   		return [DisplayHints <pkgPat>]
  2752         -	} elseif {"--" == $prev} {
         2791  +	} elseif {"--" == ${prev}} {
  2753   2792   		return [TryFromList ${text} <dir>]
  2754   2793   	}
  2755   2794   	return ${res}
  2756   2795   }
  2757   2796   
  2758   2797   proc complete(proc) {text start end line pos mod} {
  2759         -	switch -- $pos {
         2798  +	switch -- ${pos} {
  2760   2799   		1 {
  2761   2800   			set known_procs [ProcsOnlyCompletion ${text}]
  2762   2801   			return [CompleteFromList ${text} ${known_procs}]
  2763   2802   		}
  2764   2803   		2 {
  2765         -			set proc [Lindex $line 1]
         2804  +			set proc [Lindex ${line} 1]
  2766   2805   			if {[catch {set args [uplevel [info level] info args ${proc}]}]} {
  2767   2806   				return [DisplayHints <args>]
  2768   2807   			} else {
  2769   2808   				return [list "\{${args}\}"]
  2770   2809   			}
  2771   2810   		}
  2772   2811   		3 {
  2773         -			if {![string length [Lindex $line $pos]]} {
         2812  +			if {![string length [Lindex ${line} ${pos}]]} {
  2774   2813   				return [list \{ {}]; # \}
  2775   2814   			} else {
  2776   2815   				# return [DisplayHints <body>]
  2777         -				return [BraceOrCommand $text $start $end $line $pos $mod]
         2816  +				return [BraceOrCommand \
         2817  +				${text} ${start} ${end} ${line} ${pos} ${mod}]
  2778   2818   			}
  2779   2819   		}
  2780   2820   	}
  2781   2821   	return ""
  2782   2822   }
  2783   2823   
  2784   2824   proc complete(puts) {text start end line pos mod} {
................................................................................
  2825   2865   	set prev [PreviousWord ${start} ${line}]
  2826   2866   	if {[llength ${prev}] && "--" != $prev && \
  2827   2867   		("-" == [string index ${prev} 0] || 1 == $pos)} {
  2828   2868   		set cmds [RemoveUsedOptions ${line} {
  2829   2869   			-nocase -indices -expanded -line 
  2830   2870   			-linestop -lineanchor -about <expression> --} {--}]
  2831   2871   		if {[llength ${cmds}]} {
  2832         -			return [string trim [CompleteFromList $text $cmds]]
         2872  +			return [string trim [CompleteFromList ${text} ${cmds}]]
  2833   2873   		}
  2834   2874   	} else {
  2835   2875   		set virtual_pos [expr ${pos} - [FirstNonOption ${line}]]
  2836   2876   		switch -- ${virtual_pos} {
  2837   2877   			0 { return [DisplayHints <string>] }
  2838   2878   			1 { return [DisplayHints ?matchVar?] }
  2839   2879   			default { return [DisplayHints ?subMatchVar?] }
................................................................................
  2845   2885   # proc complete(regexp) {text start end line pos mod} {
  2846   2886   #     We're not on windoze here ...
  2847   2887   # }
  2848   2888   
  2849   2889   proc complete(regsub) {text start end line pos mod} {
  2850   2890   	set prev [PreviousWord ${start} ${line}]
  2851   2891   	if {[llength ${prev}] && "--" != $prev && \
  2852         -		("-" == [string index ${prev} 0] || 1 == $pos)} {
         2892  +		("-" == [string index ${prev} 0] || 1 == ${pos)}} {
  2853   2893   		set cmds [RemoveUsedOptions ${line} {
  2854   2894   			-all -nocase --} {--}]
  2855   2895   		if {[llength ${cmds}]} {
  2856         -			return [string trim [CompleteFromList $text $cmds]]
         2896  +			return [string trim [CompleteFromList ${text} ${cmds}]]
  2857   2897   		}
  2858   2898   	} else {
  2859   2899   		set virtual_pos [expr ${pos} - [FirstNonOption ${line}]]
  2860   2900   		switch -- ${virtual_pos} {
  2861   2901   			0 { return [DisplayHints <expression>] }
  2862   2902   			1 { return [DisplayHints <string>] }
  2863   2903   			2 { return [DisplayHints <subSpec>] }
................................................................................
  2866   2906   	}
  2867   2907   	return ""
  2868   2908   }
  2869   2909   
  2870   2910   proc complete(rename) {text start end line pos mod} {
  2871   2911   	switch -- $pos {
  2872   2912   		1 {
  2873         -			return [CompleteFromList $text [CommandCompletion $text]]
         2913  +			return [CompleteFromList ${text} [CommandCompletion ${text}]]
  2874   2914   		}
  2875   2915   		2 {
  2876   2916   			return [DisplayHints <newName>]
  2877   2917   		}
  2878   2918   	}
  2879   2919   	return ""
  2880   2920   }
................................................................................
  2906   2946   namespace eval safe {
  2907   2947   	catch {
  2908   2948   		namespace import \
  2909   2949   		::tclreadline::DisplayHints ::tclreadline::PreviousWord \
  2910   2950   		::tclreadline::CompleteFromList ::tclreadline::CommandCompletion \
  2911   2951   		::tclreadline::RemoveUsedOptions ::tclreadline::HostList \
  2912   2952   		::tclreadline::ChannelId ::tclreadline::Lindex \
  2913         -		::tclreadline::CompleteBoolean
         2953  +		::tclreadline::CompleteBoolean \
         2954  +		::tclreadline::WidgetChildren
  2914   2955   	}
  2915   2956   	variable opts
  2916   2957   	set opts {
  2917   2958   		-accessPath -statics -noStatics -nested -nestedLoadOk -deleteHook
  2918   2959   	}
  2919   2960   	proc SlaveOrOpts {text start line pos slave} {
  2920   2961   		set prev [PreviousWord ${start} ${line}]
................................................................................
  2932   2973   				[RemoveUsedOptions ${line} "${opts} $slave"]]
  2933   2974   			}
  2934   2975   		}
  2935   2976   	}
  2936   2977   }
  2937   2978   
  2938   2979   proc safe::complete(interpCreate) {text start end line pos mod} {
  2939         -	return [SlaveOrOpts $text $start $line $pos ?slave?]
         2980  +	return [SlaveOrOpts ${text} ${start} ${line} ${pos} ?slave?]
  2940   2981   }
  2941   2982   
  2942   2983   proc safe::complete(interpInit) {text start end line pos mod} {
  2943         -	return [SlaveOrOpts $text $start $line $pos [interp slaves]]
         2984  +	return [SlaveOrOpts ${text} ${start} ${line} ${pos} [interp slaves]]
  2944   2985   }
  2945   2986   
  2946   2987   proc safe::complete(interpConfigure) {text start end line pos mod} {
  2947   2988   	return [SlaveOrOpts $text $start $line $pos [interp slaves]]
  2948   2989   }
  2949   2990   
  2950   2991   proc safe::complete(interpDelete) {text start end line pos mod} {
  2951         -	return [CompleteFromList $text [interp slaves]]
         2992  +	return [CompleteFromList ${text} [interp slaves]]
  2952   2993   }
  2953   2994   
  2954   2995   proc safe::complete(interpAddToAccessPath) {text start end line pos mod} {
  2955         -	switch -- $pos {
  2956         -		1 { return [CompleteFromList $text [interp slaves]] }
         2996  +	switch -- ${pos} {
         2997  +		1 { return [CompleteFromList ${text} [interp slaves]] }
  2957   2998   	}
  2958   2999   }
  2959   3000   
  2960   3001   proc safe::complete(interpFindInAccessPath) {text start end line pos mod} {
  2961         -	switch -- $pos {
  2962         -		1 { return [CompleteFromList $text [interp slaves]] }
         3002  +	switch -- ${pos} {
         3003  +		1 { return [CompleteFromList ${text} [interp slaves]] }
  2963   3004   	}
  2964   3005   }
  2965   3006   
  2966   3007   proc safe::complete(setLogCmd) {text start end line pos mod} {
  2967         -	switch -- $pos {
         3008  +	switch -- ${pos} {
  2968   3009   		1 { return [DisplayHints ?cmd?] }
  2969   3010   		default { return [DisplayHints ?arg?] }
  2970   3011   	}
  2971   3012   }
         3013  +
         3014  +proc safe::complete(loadTk) {text start end line pos mod} {
         3015  +	switch -- ${pos} {
         3016  +		1 { return [DisplayHints <slave>] }
         3017  +		default {
         3018  +			switch -- [PreviousWord ${start} ${line}] {
         3019  +				-use {
         3020  +					return [CompleteFromList ${text} \
         3021  +					[::tclreadline::WidgetChildren ${text}]]
         3022  +				}
         3023  +				-display {
         3024  +					return [DisplayHints <display>]
         3025  +				}
         3026  +				default {
         3027  +					return [CompleteFromList ${text} \
         3028  +					[RemoveUsedOptions ${line} {-use -display}]]
         3029  +				}
         3030  +			}
         3031  +		}
         3032  +	}
         3033  +}
  2972   3034   
  2973   3035   # --- END OF SAFE PACKAGE ---
  2974   3036   
  2975   3037   proc complete(scan) {text start end line pos mod} {
  2976         -	switch -- $pos {
         3038  +	switch -- ${pos} {
  2977   3039   		1 { return [DisplayHints <string>] }
  2978   3040   		2 { return [DisplayHints <format>] }
  2979   3041   		default { return [VarCompletion ${text}] }
  2980   3042   	}
  2981   3043   	return ""
  2982   3044   }
  2983   3045   
  2984   3046   proc complete(seek) {text start end line pos mod} {
  2985         -	switch -- $pos {
         3047  +	switch -- ${pos} {
  2986   3048   		1 { return [ChannelId ${text}] }
  2987   3049   		2 { return [DisplayHints <offset>] }
  2988   3050   		3 { return [TryFromList ${text} {start current end}] }
  2989   3051   	}
  2990   3052   	return ""
  2991   3053   }
  2992   3054   
  2993   3055   proc complete(set) {text start end line pos mod} {
  2994         -	switch -- $pos {
         3056  +	switch -- ${pos} {
  2995   3057   		1 { return [VarCompletion ${text}] }
  2996   3058   		2 {
  2997         -			if {$text == "" || $text == "\"" || $text == "\{"} {
         3059  +			if {${text} == "" || ${text} == "\"" || ${text} == "\{"} {
  2998   3060   				# set line [QuoteQuotes $line]
  2999   3061   				if {[catch [list set value [list [uplevel [info level] \
  3000         -					set [Lindex $line 1]]]] msg]
         3062  +					set [Lindex ${line} 1]]]] msg]
  3001   3063   				} {
  3002   3064   					return ""
  3003   3065   				} else {
  3004         -					return [Quote $value ${text}]
         3066  +					return [Quote ${value} ${text}]
  3005   3067   				}
  3006   3068   			}
  3007   3069   		}
  3008   3070   	}
  3009   3071   	return ""
  3010   3072   }
  3011   3073   
  3012   3074   proc complete(socket) {text start end line pos mod} {
  3013   3075   	set cmd [Lindex ${line} 1]
  3014   3076   	set prev [PreviousWord ${start} ${line}]
  3015   3077   	if {"-server" == ${cmd}} {
  3016   3078   		# server sockets
  3017   3079   		#
  3018         -		switch -- $pos {
         3080  +		switch -- ${pos} {
  3019   3081   			2 { return [DisplayHints <command>] }
  3020   3082   			default {
  3021         -				if {"-myaddr" == $prev} {
         3083  +				if {"-myaddr" == ${prev}} {
  3022   3084   					return [DisplayHints <addr>]
  3023   3085   				} else {
  3024   3086   					return [CompleteFromList ${mod} \
  3025   3087   					[RemoveUsedOptions $line {-myaddr -error -sockname <port>}]]
  3026   3088   				}
  3027   3089   			}
  3028   3090   		}
................................................................................
  3032   3094   		switch -- ${prev} {
  3033   3095   			-myaddr { return [DisplayHints <addr>] }
  3034   3096   			-myport { return [DisplayHints <port>] }
  3035   3097   		}
  3036   3098   
  3037   3099   		set hosts [HostList]
  3038   3100   		set cmds {-myaddr -myport -async -myaddr -error -sockname -peername}
  3039         -		if {$pos <= 1} {
         3101  +		if {${pos} <= 1} {
  3040   3102   			lappend cmds -server
  3041   3103   		}
  3042         -		set cmds [RemoveUsedOptions $line $cmds]
  3043         -		if {-1 != [lsearch $hosts $prev]} {
         3104  +		set cmds [RemoveUsedOptions ${line} ${cmds}]
         3105  +		if {-1 != [lsearch ${hosts} ${prev}]} {
  3044   3106   			return [DisplayHints <port>]
  3045   3107   		} else {
  3046   3108   			return [CompleteFromList ${mod} [concat ${cmds} ${hosts}]]
  3047   3109   		}
  3048   3110   	}
  3049   3111   	return ""
  3050   3112   }
  3051   3113   
  3052         -# proc complete(source) {text start end line pos mod} {
  3053         -# }
         3114  +proc complete(source) {text start end line pos mod} {
         3115  +	# allow file name completion
         3116  +	return ""
         3117  +}
  3054   3118   
  3055   3119   proc complete(split) {text start end line pos mod} {
  3056         -	switch -- $pos {
         3120  +	switch -- ${pos} {
  3057   3121   		1 { return [DisplayHints <string>] }
  3058   3122   		2 { return [DisplayHints ?splitChars?] }
  3059   3123   	}
  3060   3124   }
  3061   3125   
  3062   3126   proc complete(string) {text start end line pos mod} {
  3063   3127   	set cmd [Lindex ${line} 1]
  3064   3128   	set prev [PreviousWord ${start} ${line}]
  3065   3129   	set cmds {
  3066   3130   		bytelength compare equal first index is last length map match
  3067   3131   		range repeat replace tolower toupper totitle trim trimleft
  3068   3132   		trimright wordend wordstart}
  3069         -	switch -- $pos {
         3133  +	switch -- ${pos} {
  3070   3134   		1 {
  3071   3135   			return [CompleteFromList ${text} ${cmds}]
  3072   3136   		}
  3073   3137   		2 {
  3074         -			switch -- $cmd {
         3138  +			switch -- ${cmd} {
  3075   3139   				compare -
  3076   3140   				equal {
  3077   3141   					return [CompleteFromList ${text} {
  3078   3142   						-nocase -length <string> }]
  3079   3143   				}
  3080   3144   
  3081   3145   				first -
................................................................................
  3105   3169   				trimleft -
  3106   3170   				trimright -
  3107   3171   				wordend -
  3108   3172   				wordstart { return [DisplayHints <string>] }
  3109   3173   			}
  3110   3174   		}
  3111   3175   		3 {
  3112         -			switch -- $cmd {
         3176  +			switch -- ${cmd} {
  3113   3177   				compare -
  3114   3178   				equal {
  3115         -					if {"-length" == $prev} {
         3179  +					if {"-length" == ${prev}} {
  3116   3180   						return [DisplayHints <int>]
  3117   3181   					}
  3118   3182   					return [CompleteFromList ${text} \
  3119         -					[RemoveUsedOptions $line {-nocase -length <string>}]]
         3183  +					[RemoveUsedOptions ${line} {-nocase -length <string>}]]
  3120   3184   				}
  3121   3185   
  3122   3186   				first -
  3123   3187   				last { return [DisplayHints <string2>] }
  3124   3188   
  3125   3189   				map {
  3126         -					if {"-nocase" == $prev} {
         3190  +					if {"-nocase" == ${prev}} {
  3127   3191   						return [DisplayHints <charMap>]
  3128   3192   					} else {
  3129   3193   						return [DisplayHints <string>]
  3130   3194   					}
  3131   3195   				}
  3132   3196   				match {
  3133         -					if {"-nocase" == $prev} {
         3197  +					if {"-nocase" == ${prev}} {
  3134   3198   						return [DisplayHints <pattern>]
  3135   3199   					} else {
  3136   3200   						return [DisplayHints <string>]
  3137   3201   					}
  3138   3202   				}
  3139   3203   
  3140   3204   				is {
  3141   3205   					return [CompleteFromList ${text} \
  3142         -					[RemoveUsedOptions $line {-strict -failindex <string>}]]
         3206  +					[RemoveUsedOptions ${line} {-strict -failindex <string>}]]
  3143   3207   				}
  3144   3208   
  3145   3209   				bytelength {}
  3146   3210   				index -
  3147   3211   				wordend -
  3148   3212   				wordstart { return [DisplayHints <charIndex>] }
  3149   3213   				range -
................................................................................
  3154   3218   				toupper { return [DisplayHints ?first?] }
  3155   3219   				trim -
  3156   3220   				trimleft -
  3157   3221   				trimright { return [DisplayHints ?chars?] }
  3158   3222   			}
  3159   3223   		}
  3160   3224   		4 {
  3161         -			switch -- $cmd {
         3225  +			switch -- ${cmd} {
  3162   3226   				compare -
  3163   3227   				equal {
  3164         -					if {"-length" == $prev} {
         3228  +					if {"-length" == ${prev}} {
  3165   3229   						return [DisplayHints <int>]
  3166   3230   					}
  3167   3231   					return [CompleteFromList ${text} \
  3168   3232   					[RemoveUsedOptions $line {-nocase -length <string>}]]
  3169   3233   				}
  3170   3234   
  3171   3235   				first -
  3172   3236   				last { return [DisplayHints ?startIndex?] }
  3173   3237   
  3174   3238   				map -
  3175   3239   				match { return [DisplayHints <string>] }
  3176   3240   
  3177   3241   				is {
  3178         -					if {"-failindex" == $prev} {
         3242  +					if {"-failindex" == ${prev}} {
  3179   3243   						return [VarCompletion ${text}]
  3180   3244   					}
  3181   3245   					return [CompleteFromList ${text} \
  3182   3246   					[RemoveUsedOptions $line {-strict -failindex <string>}]]
  3183   3247   				}
  3184   3248   
  3185   3249   				bytelength {}
................................................................................
  3195   3259   				trimleft -
  3196   3260   				trimright {}
  3197   3261   				wordend -
  3198   3262   				wordstart {}
  3199   3263   			}
  3200   3264   		}
  3201   3265   		default {
  3202         -			switch -- $cmd {
         3266  +			switch -- ${cmd} {
  3203   3267   				compare -
  3204   3268   				equal {
  3205         -					if {"-length" == $prev} {
         3269  +					if {"-length" == ${prev}} {
  3206   3270   						return [DisplayHints <int>]
  3207   3271   					}
  3208   3272   					return [CompleteFromList ${text} \
  3209   3273   					[RemoveUsedOptions $line {-nocase -length <string>}]]
  3210   3274   				}
  3211   3275   
  3212   3276   				is {
  3213         -					if {"-failindex" == $prev} {
         3277  +					if {"-failindex" == ${prev}} {
  3214   3278   						return [VarCompletion ${text}]
  3215   3279   					}
  3216   3280   					return [CompleteFromList ${text} \
  3217         -					[RemoveUsedOptions $line {-strict -failindex <string>}]]
         3281  +					[RemoveUsedOptions ${line} {-strict -failindex <string>}]]
  3218   3282   				}
  3219   3283   
  3220   3284   				replace { return [DisplayHints ?newString?] }
  3221   3285   			}
  3222   3286   		}
  3223   3287   	}
  3224   3288   	return ""
  3225   3289   }
  3226   3290   
  3227   3291   proc complete(subst) {text start end line pos mod} {
  3228         -	return [CompleteFromList ${text} [RemoveUsedOptions $line {
         3292  +	return [CompleteFromList ${text} [RemoveUsedOptions ${line} {
  3229   3293   		-nobackslashes -nocommands -novariables <string>}]]
  3230   3294   }
  3231   3295   
  3232   3296   proc complete(switch) {text start end line pos mod} {
  3233   3297   	set prev [PreviousWord ${start} ${line}]
  3234         -	if {[llength ${prev}] && "--" != $prev && \
  3235         -		("-" == [string index ${prev} 0] || 1 == $pos)} {
         3298  +	if {[llength ${prev}] && "--" != ${prev} && \
         3299  +		("-" == [string index ${prev} 0] || 1 == ${pos)}} {
  3236   3300   		set cmds [RemoveUsedOptions ${line} {
  3237   3301   			-exact -glob -regexp --} {--}]
  3238   3302   		if {[llength ${cmds}]} {
  3239         -			return [string trim [CompleteFromList $text $cmds]]
         3303  +			return [string trim [CompleteFromList ${text} ${cmds}]]
  3240   3304   		}
  3241   3305   	} else {
  3242   3306   		set virtual_pos [expr ${pos} - [FirstNonOption ${line}]]
  3243   3307   		switch -- ${virtual_pos} {
  3244   3308   			0 { return [DisplayHints <string>] }
  3245   3309   			1 { return [DisplayHints <pattern>] }
  3246   3310   			2 { return [DisplayHints <body>] }
  3247   3311   			default { 
  3248         -				switch [expr $virtual_pos % 2] {
         3312  +				switch [expr ${virtual_pos} % 2] {
  3249   3313   					0 { return [DisplayHints ?body?] }
  3250   3314   					1 { return [DisplayHints ?pattern?] }
  3251   3315   				}
  3252   3316   			}
  3253   3317   		}
  3254   3318   	}
  3255   3319   	return ""
................................................................................
  3267   3331   		::tclreadline::CompleteFromList \
  3268   3332   		::tclreadline::Lindex \
  3269   3333   		::tclreadline::CompleteBoolean
  3270   3334   	}
  3271   3335   }
  3272   3336   
  3273   3337   proc tclreadline::complete(readline) {text start end line pos mod} {
  3274         -	set cmd [Lindex $line 1]
  3275         -	switch -- $pos {
         3338  +	set cmd [Lindex ${line} 1]
         3339  +	switch -- ${pos} {
  3276   3340   		1 { return [CompleteFromList ${text} {
  3277   3341   			read initialize write add complete
  3278   3342   			customcompleter builtincompleter eofchar reset-terminal}]
  3279   3343   		}
  3280   3344   		2 {
  3281         -			switch -- $cmd {
         3345  +			switch -- ${cmd} {
  3282   3346   				read {}
  3283   3347   				initialize {}
  3284   3348   				write {}
  3285   3349   				add { return [DisplayHints <completerLine>] }
  3286   3350   				completer { return [DisplayHints <line>] }
  3287   3351   				customcompleter { return [DisplayHints ?scriptCompleter?] }
  3288   3352   				builtincompleter { return [CompleteBoolean ${text}] }
................................................................................
  3299   3363   	}
  3300   3364   	return ""
  3301   3365   }
  3302   3366   
  3303   3367   # --- END OF TCLREADLINE PACKAGE ---
  3304   3368   
  3305   3369   proc complete(tell) {text start end line pos mod} {
  3306         -	switch -- $pos {
         3370  +	switch -- ${pos} {
  3307   3371   		1 { return [ChannelId ${text}] }
  3308   3372   	}
  3309   3373   	return ""
  3310   3374   }
  3311   3375   
  3312   3376   proc complete(time) {text start end line pos mod} {
  3313         -	switch -- $pos {
  3314         -		1 { return [BraceOrCommand $text $start $end $line $pos $mod] }
         3377  +	switch -- ${pos} {
         3378  +		1 { return [BraceOrCommand \
         3379  +			${text} ${start} ${end} ${line} ${pos} ${mod}]
         3380  +		}
  3315   3381   		2 { return [DisplayHints ?count?] }
  3316   3382   	}
  3317   3383   	return ""
  3318   3384   }
  3319   3385   
  3320   3386   proc complete(trace) {text start end line pos mod} {
  3321   3387   	set cmd [Lindex ${line} 1]
  3322         -	switch -- $pos {
         3388  +	switch -- ${pos} {
  3323   3389   		1 {
  3324   3390   			return [CompleteFromList ${mod} {variable vdelete vinfo}]
  3325   3391   		}
  3326   3392   		2 {
  3327   3393   			return [CompleteFromList ${text} \
  3328   3394   			[uplevel [info level] info vars "${mod}*"]]
  3329   3395   		}
  3330   3396   		3 {
  3331         -			switch -- $cmd {
         3397  +			switch -- ${cmd} {
  3332   3398   				variable -
  3333   3399   				vdelete { return [CompleteFromList ${text} {r w u}] }
  3334   3400   			}
  3335   3401   		}
  3336   3402   		4 {
  3337         -			switch -- $cmd {
         3403  +			switch -- ${cmd} {
  3338   3404   				variable -
  3339   3405   				vdelete {
  3340         -					return [CompleteFromList $text [CommandCompletion $text]]
         3406  +					return [CompleteFromList ${text} \
         3407  +					[CommandCompletion ${text}]]
  3341   3408   				}
  3342   3409   			}
  3343   3410   		}
  3344   3411   	}
  3345   3412   	return ""
  3346   3413   }
  3347   3414   
  3348   3415   proc complete(unknown) {text start end line pos mod} {
  3349         -	switch -- $pos {
         3416  +	switch -- ${pos} {
  3350   3417   		1 {
  3351         -			return [CompleteFromList $text [CommandCompletion $text]]
         3418  +			return [CompleteFromList ${text} [CommandCompletion ${text}]]
  3352   3419   		}
  3353   3420   		default { return [DisplayHints ?arg?] }
  3354   3421   	}
  3355   3422   	return ""
  3356   3423   }
  3357   3424   
  3358   3425   proc complete(unset) {text start end line pos mod} {
  3359   3426   	return [VarCompletion ${text}]
  3360   3427   }
  3361   3428   
  3362   3429   proc complete(update) {text start end line pos mod} {
  3363         -	switch -- $pos {
         3430  +	switch -- ${pos} {
  3364   3431   		1 { return idletasks }
  3365   3432   	}
  3366   3433   	return ""
  3367   3434   }
  3368   3435   
  3369   3436   proc complete(uplevel) {text start end line pos mod} {
  3370   3437   	set one [Lindex ${line} 1]
  3371         -	switch -- $pos {
         3438  +	switch -- ${pos} {
  3372   3439   		1 {
  3373         -			return [CompleteFromList $text "?level? [CommandCompletion $text]"]
         3440  +			return [CompleteFromList \
         3441  +			${text} "?level? [CommandCompletion ${text}]"]
  3374   3442   		}
  3375   3443   		2 {
  3376         -			if {"#" == [string index $one 0] || [regexp {^[0-9]*$} $one]} {
  3377         -				return [CompleteFromList $text [CommandCompletion $text]]
         3444  +			if {"#" == [string index ${one} 0] || [regexp {^[0-9]*$} ${one}]} {
         3445  +				return [CompleteFromList ${text} [CommandCompletion ${text}]]
  3378   3446   			} else {
  3379   3447   				return [DisplayHints ?arg?]
  3380   3448   			}
  3381   3449   		}
  3382   3450   		default { return [DisplayHints ?arg?] }
  3383   3451   	}
  3384   3452   	return ""
................................................................................
  3506   3574   # 	return [CompleteFromOptionsOrSubCmds ${text} ${start} ${end} ${line} ${pos}]
  3507   3575   # }
  3508   3576   
  3509   3577   proc EventuallyInsertLeadingDot {text fallback} {
  3510   3578   	if {![string length ${text}]} {
  3511   3579   		return [list . {}]
  3512   3580   	} else {
  3513         -		return [DisplayHints $fallback]
         3581  +		return [DisplayHints ${fallback}]
  3514   3582   	}
  3515   3583   }
         3584  +
         3585  +# TODO
         3586  +proc CompleteColor text {
         3587  +	return [DisplayHints <color>]
         3588  +}
  3516   3589   
  3517   3590   #**
  3518   3591   # SpecificSwitchCompleter
  3519   3592   # ---
  3520   3593   # @param    text   -- the word to complete.
  3521   3594   # @param    start  -- the char index of text's start in line
  3522   3595   # @param    line   -- the line gathered so far.
................................................................................
  3525   3598   # @sa       CompleteWidgetConfigurations
  3526   3599   # @date     Sep-17-1999
  3527   3600   #
  3528   3601   proc SpecificSwitchCompleter {text start line switch} {
  3529   3602   	# TODO:
  3530   3603   	#   go to the `options' man page and look for possible values
  3531   3604   	switch -- ${switch} {
  3532         -		-takefocus -
  3533         -		-exportselection { return [CompleteBoolean ${text}] }
  3534         -		-xscrollcommand -
  3535         -		-yscrollcommand {
  3536         -			# return [BraceOrCommand ${text} \
  3537         -			# ${start} ${end} ${line} ${pos} ${mod}]
         3605  +
         3606  +		-activebackground -
         3607  +		-activeforeground -
         3608  +		-fg -
         3609  +		-foreground -
         3610  +		-bg -
         3611  +		-background -
         3612  +		-disabledforeground -
         3613  +		-highlightbackground -
         3614  +		-highlightcolor -
         3615  +		-insertbackground -
         3616  +		-troughcolor -
         3617  +		-selectbackground -
         3618  +		-selectforeground { return [CompleteColor ${text}] }
         3619  +
         3620  +		-activeborderwidth -
         3621  +		-bd -
         3622  +		-borderwidth -
         3623  +		-insertborderwidth -
         3624  +		-insertwidth -
         3625  +		-selectborderwidth -
         3626  +		-highlightthickness -
         3627  +		-padx -
         3628  +		-pady -
         3629  +		-wraplength {
         3630  +			return [DisplayHints <pixels>]
         3631  +		}
         3632  +
         3633  +		-anchor {
         3634  +			return [CompleteFromList ${text} {
         3635  +				n ne e se s sw w nw center
         3636  +			}]
         3637  +		}
         3638  +
         3639  +
         3640  +		-bitmap { return [CompleteFromBitmaps ${text}] }
         3641  +
         3642  +
         3643  +		-cursor { return [DisplayHints <cursor>] }
         3644  +		-exportselection -
         3645  +		-jump -
         3646  +		-setgrid -
         3647  +		-takefocus { return [CompleteBoolean ${text}] }
         3648  +		-font {
         3649  +			set names [font names]
         3650  +			if {[string length ${names}]} {
         3651  +				return [CompleteFromList ${text} ${names}]
         3652  +			} else {
         3653  +				return [DisplayHints <font>]
         3654  +			}
         3655  +		}
         3656  +
         3657  +
         3658  +		-image -
         3659  +		-selectimage {
         3660  +			set images [image names]
         3661  +			if {[string length ${images}]} {
         3662  +				return [CompleteFromList ${text} ${images}]
         3663  +			} else {
         3664  +				return [DisplayHints <image>]
         3665  +			}
         3666  +		}
         3667  +
         3668  +		-insertofftime -
         3669  +		-insertontime -
         3670  +		-repeatdelay -
         3671  +		-repeatinterval { return [DisplayHints <milliSec>] }
         3672  +		-justify {
         3673  +			return [CompleteFromList ${text} {
         3674  +				left center right
         3675  +			}]
         3676  +		}
         3677  +		-orient {
         3678  +			return [CompleteFromList ${text} {
         3679  +				vertical horizontal
         3680  +			}]
  3538   3681   		}
  3539   3682   		-relief {
  3540   3683   			return [CompleteFromList ${text} {
  3541   3684   				raised sunken flat ridge solid groove
  3542   3685   			}]
  3543   3686   		}
         3687  +
         3688  +		-text { return [DisplayHints <text>] }
         3689  +		-textvariable { return [VarCompletion ${text} #0] }
         3690  +		-underline { return [DisplayHints <index>] }
         3691  +
         3692  +-xscrollcommand -
         3693  +-yscrollcommand {
         3694  +}
         3695  + 
         3696  +        # WIDGET SPECIFIC OPTIONS
         3697  +		# ---
         3698  + 
         3699  +		-state {
         3700  +			return [CompleteFromList ${text} {
         3701  +				normal active disabled
         3702  +			}]
         3703  +		}
         3704  +
         3705  +		-columnbreak -
         3706  +		-hidemargin -
         3707  +		-indicatoron {
         3708  +			return [CompleteBoolean ${text}]
         3709  +		}
         3710  +
         3711  +		-variable {
         3712  +			return [VarCompletion ${text} #0]
         3713  +		}
         3714  +
  3544   3715   		default {
  3545   3716   			set prev [PreviousWord ${start} ${line}]
  3546   3717   			return [DisplayHints <[String range ${prev} 1 end]>]
  3547   3718   		}
  3548   3719   	}
  3549   3720   }
         3721  +			# return [BraceOrCommand ${text} \
         3722  +			# ${start}  ${line} ${pos} ${mod}]
  3550   3723   
  3551   3724   #**
  3552   3725   # CompleteWidgetConfigurations
  3553   3726   # ---
  3554   3727   # @param    text  -- the word to complete.
  3555   3728   # @param    start -- the actual cursor position.
  3556   3729   # @param    line  -- the line gathered so far.
................................................................................
  3616   3789   				Scale Scrollbar Text
  3617   3790   				all
  3618   3791   			}
  3619   3792   			return [CompleteFromList ${text} \
  3620   3793   			[concat ${toplevels} ${widgets} ${toplevelClass} $rest]]
  3621   3794   		}
  3622   3795   		2 {
  3623         -			set fulltext [Lindex $line 2]
  3624         -			return [CompleteSequence ${text} ${fulltext}]
         3796  +			return [CompleteSequence ${text} [Lindex ${line} 2]]
  3625   3797   		}
  3626   3798   		default {
  3627   3799   			# return [DisplayHints {<script> <+script>}]
  3628   3800   			return [BraceOrCommand ${text} \
  3629   3801   			${start} ${end} ${line} ${pos} ${mod}]
  3630   3802   		}
  3631   3803   	}
................................................................................
  3636   3808   	switch -- ${pos} {
  3637   3809   		1 { return [CompleteFromList ${text} [WidgetChildren ${text}]] }
  3638   3810   		2 {
  3639   3811   			# set current_tags \
  3640   3812   			# [RemoveUsedOptions ${line} [bindtags [Lindex ${line} 1]]]
  3641   3813   			set current_tags [bindtags [Lindex ${line} 1]]
  3642   3814   			return [CompleteListFromList ${text} [Lindex ${line} 2] \
  3643         -			$current_tags \{ { } \}]
         3815  +			${current_tags} \{ { } \}]
  3644   3816   		}
  3645   3817   	}
  3646   3818   	return ""
  3647   3819   }
  3648   3820   
  3649   3821   proc complete(button) {text start end line pos mod} {
  3650   3822   	switch -- ${pos} {
................................................................................
  3765   3937   				-takefocus -textvariable -xscrollcommand -show -state
  3766   3938   				-width
  3767   3939   			}]
  3768   3940   		}
  3769   3941   	}
  3770   3942   	return ""
  3771   3943   }
         3944  +
         3945  +proc complete(event) {text start end line pos mod} {
         3946  +	set sub [Lindex ${line} 1]
         3947  +	switch -- ${pos} {
         3948  +		1 {
         3949  +			return [CompleteFromList ${text} { add delete generate info }]
         3950  +		}
         3951  +		2 {
         3952  +			switch -- ${sub} {
         3953  +				add { return [DisplayHints <<virtual>>] }
         3954  +				info -
         3955  +				delete {
         3956  +					return [CompleteFromList ${text} [event info] "<"]
         3957  +				}
         3958  +				generate {
         3959  +					return [TryFromList ${text} [WidgetChildren ${text}]]
         3960  +				}
         3961  +			}
         3962  +		}
         3963  +		3 {
         3964  +			switch -- ${sub} {
         3965  +				add -
         3966  +				delete -
         3967  +				generate {
         3968  +					return [CompleteSequence ${text} [Lindex ${line} 3]]
         3969  +				}
         3970  +				info {}
         3971  +			}
         3972  +		}
         3973  +		default {
         3974  +			switch -- ${sub} {
         3975  +				add -
         3976  +				delete {
         3977  +					return [CompleteSequence ${text} [Lindex ${line} 3]]
         3978  +				}
         3979  +				info {}
         3980  +				generate {
         3981  +
         3982  +					switch -- [PreviousWord ${start} ${line}] {
         3983  +
         3984  +						-above -
         3985  +						-root -
         3986  +						-subwindow {
         3987  +							return [TryFromList ${text} \
         3988  +							[WidgetChildren ${text}]]
         3989  +						}
         3990  +
         3991  +						-borderwidth { return [DisplayHints <size>] }
         3992  +
         3993  +						-button -
         3994  +						-delta -
         3995  +						-keycode -
         3996  +						-serial -
         3997  +						-count { return [DisplayHints <number>] }
         3998  +
         3999  +						-detail {
         4000  +							return [CompleteFromList ${text} { 
         4001  +								NotifyAncestor    NotifyNonlinearVirtual
         4002  +								NotifyDetailNone  NotifyPointer
         4003  +								NotifyInferior    NotifyPointerRoot
         4004  +								NotifyNonlinear   NotifyVirtual
         4005  +							}]
         4006  +						}
         4007  +
         4008  +						-focus -
         4009  +						-override -
         4010  +						-sendevent { return [CompleteBoolean ${text}] }
         4011  +
         4012  +						-height -
         4013  +						-width { return [DisplayHints <size>] }
         4014  +
         4015  +						-keysym { return [DisplayHints <name>] }
         4016  +
         4017  +						-mode {
         4018  +							return [CompleteFromList ${text} { 
         4019  +								NotifyNormal NotifyGrab
         4020  +								NotifyUngrab NotifyWhileGrabbed
         4021  +							}]
         4022  +						}
         4023  +
         4024  +						-place {
         4025  +							return [CompleteFromList ${text} { 
         4026  +								PlaceOnTop PlaceOnBottom
         4027  +							}]
         4028  +						}
         4029  +
         4030  +						-rootx -
         4031  +						-rooty -
         4032  +						-x -
         4033  +						-y { return [DisplayHints <coord>] }
         4034  +
         4035  +						-state {
         4036  +							return [CompleteFromList ${text} { 
         4037  +								VisibilityUnobscured
         4038  +								VisibilityPartiallyObscured
         4039  +								VisibilityFullyObscured
         4040  +								<integer>
         4041  +							}]
         4042  +						}
         4043  +
         4044  +						-time { return [DisplayHints <integer>] }
         4045  +						-when {
         4046  +							return [CompleteFromList ${text} { 
         4047  +								now tail head mark
         4048  +							}]
         4049  +						}
         4050  +
         4051  +						default {
         4052  +							return [CompleteFromList ${text} \
         4053  +							[RemoveUsedOptions ${line} {
         4054  +								-above -borderwidth -button -count -delta
         4055  +								-detail -focus -height -keycode -keysym
         4056  +								-mode -override -place -root -rootx -rooty
         4057  +								-sendevent -serial -state -subwindow -time
         4058  +								-width -when -x -y
         4059  +							}]]
         4060  +
         4061  +						}
         4062  +					}
         4063  +					default { }
         4064  +				}
         4065  +			}
         4066  +		}
         4067  +	}
         4068  +	return ""
         4069  +}
         4070  +
         4071  +proc complete(focus) {text start end line pos mod} {
         4072  +	switch -- ${pos} {
         4073  +		1 {
         4074  +			return [CompleteFromList ${text} \
         4075  +			[concat [WidgetChildren ${text}] -displayof -force -lastfor]]
         4076  +		}
         4077  +		default {
         4078  +			switch -- [PreviousWord ${start} ${line}] {
         4079  +				-displayof -
         4080  +				-force -
         4081  +				-lastfor {
         4082  +					return [CompleteFromList ${text} \
         4083  +					[WidgetChildren ${text}]]
         4084  +				}
         4085  +			}
         4086  +		}
         4087  +	}
         4088  +	return ""
         4089  +}
         4090  +
         4091  +proc FontConfigure {text line prev} {
         4092  +	set fontopts {-family -overstrike -size -slant -underline -weight}
         4093  +	switch -- ${prev} {
         4094  +		-family {
         4095  +			return [CompleteFromList ${text} [font families]]
         4096  +		}
         4097  +		-underline -
         4098  +		-overstrike { return [CompleteBoolean ${text}] }
         4099  +		-size { return [DisplayHints <size>] }
         4100  +		-slant {
         4101  +			return [CompleteFromList ${text} { roman italic }]
         4102  +		}
         4103  +		-weight {
         4104  +			return [CompleteFromList ${text} { normal bold }]
         4105  +		}
         4106  +		default {
         4107  +			return [CompleteFromList ${text} \
         4108  +			[RemoveUsedOptions ${line} ${fontopts}]]
         4109  +		}
         4110  +	}
         4111  +}
         4112  +
         4113  +proc complete(font) {text start end line pos mod} {
         4114  +	set fontopts {-family -overstrike -size -slant -underline -weight}
         4115  +	set fontmetrics {-ascent -descent -linespace -fixed}
         4116  +	set sub [Lindex ${line} 1]
         4117  +	set prev [PreviousWord ${start} ${line}]
         4118  +	switch -- ${pos} {
         4119  +		1 {
         4120  +			return [CompleteFromList ${text} {
         4121  +				actual configure create delete families measure metrics names
         4122  +			}]
         4123  +		}
         4124  +		2 {
         4125  +			switch -- ${sub} {
         4126  +				actual -
         4127  +				measure -
         4128  +				metrics {
         4129  +					return [DisplayHints <font>]
         4130  +				}
         4131  +				configure -
         4132  +				delete {
         4133  +					set names [font names]
         4134  +					if {[string length ${names}]} {
         4135  +						return [CompleteFromList ${text} ${names}]
         4136  +					} else {
         4137  +						return [DisplayHints <fontname>]
         4138  +					}
         4139  +				}
         4140  +				create {
         4141  +					return [CompleteFromList ${text} \
         4142  +					[concat ?fontname? ${fontopts}]]
         4143  +				}
         4144  +				families {
         4145  +					return [CompleteFromList ${text} -displayof]
         4146  +				}
         4147  +				names {}
         4148  +			}
         4149  +		}
         4150  +		3 {
         4151  +			switch -- ${sub} {
         4152  +				actual {
         4153  +					return [CompleteFromList ${text} \
         4154  +					[concat -displayof ${fontopts}]]
         4155  +				}
         4156  +				configure -
         4157  +				create {
         4158  +					return [FontConfigure ${text} ${line} ${prev}]
         4159  +				}
         4160  +				delete {
         4161  +					set names [font names]
         4162  +					if {[string length ${names}]} {
         4163  +						return [CompleteFromList ${text} ${names}]
         4164  +					} else {
         4165  +						return [DisplayHints <fontname>]
         4166  +					}
         4167  +				}
         4168  +				families {
         4169  +					switch -- ${prev} {
         4170  +						-displayof {
         4171  +							return [CompleteFromList ${text} \
         4172  +							[WidgetChildren ${text}]]
         4173  +						}
         4174  +					}
         4175  +				}
         4176  +				measure {
         4177  +					return [CompleteFromList ${text} {-displayof <text>}]
         4178  +				}
         4179  +				metrics {
         4180  +					return [CompleteFromList ${text} \
         4181  +					[concat -displayof ${fontmetrics}]]
         4182  +				}
         4183  +				names {}
         4184  +			}
         4185  +		}
         4186  +		4 {
         4187  +			switch -- ${sub} {
         4188  +				actual {
         4189  +					switch -- ${prev} {
         4190  +						-displayof {
         4191  +							return [CompleteFromList ${text} \
         4192  +							[WidgetChildren ${text}]]
         4193  +						}
         4194  +						default {
         4195  +							return [FontConfigure ${text} ${line} ${prev}]
         4196  +						}
         4197  +					}
         4198  +				}
         4199  +				configure -
         4200  +				create {
         4201  +					return [FontConfigure ${text} ${line} ${prev}]
         4202  +				}
         4203  +				delete {
         4204  +					set names [font names]
         4205  +					if {[string length ${names}]} {
         4206  +						return [CompleteFromList ${text} ${names}]
         4207  +					} else {
         4208  +						return [DisplayHints <fontname>]
         4209  +					}
         4210  +				}
         4211  +				families {}
         4212  +				measure {
         4213  +					switch -- ${prev} {
         4214  +						-displayof {
         4215  +							return [CompleteFromList ${text} \
         4216  +							[WidgetChildren ${text}]]
         4217  +						}
         4218  +						default {
         4219  +							return [DisplayHints <text>]
         4220  +						}
         4221  +					}
         4222  +				}
         4223  +				metrics {
         4224  +					switch -- ${prev} {
         4225  +						-displayof {
         4226  +							return [CompleteFromList ${text} \
         4227  +							[WidgetChildren ${text}]]
         4228  +						}
         4229  +						default {
         4230  +							return [CompleteFromList ${text} ${fontmetrics}]
         4231  +						}
         4232  +					}
         4233  +				}
         4234  +				names {}
         4235  +			}
         4236  +		}
         4237  +		default {
         4238  +			switch -- ${sub} {
         4239  +				actual -
         4240  +				configure -
         4241  +				create {
         4242  +					return [FontConfigure ${text} ${line} ${prev}]
         4243  +				}
         4244  +				delete {
         4245  +					set names [font names]
         4246  +					if {[string length ${names}]} {
         4247  +						return [CompleteFromList ${text} ${names}]
         4248  +					} else {
         4249  +						return [DisplayHints <fontname>]
         4250  +					}
         4251  +				}
         4252  +				families {}
         4253  +				measure {
         4254  +					return [DisplayHints <text>]
         4255  +				}
         4256  +				metrics {
         4257  +					return [CompleteFromList ${text} ${fontmetrics}]
         4258  +				}
         4259  +				names {}
         4260  +			}
         4261  +		}
         4262  +	}
         4263  +	return ""
         4264  +}
  3772   4265   
  3773   4266   proc complete(frame) {text start end line pos mod} {
  3774   4267   	switch -- ${pos} {
  3775   4268   		1 { return [EventuallyInsertLeadingDot ${text} <pathName>] }
  3776   4269   		default {
  3777   4270   			return [CompleteWidgetConfigurations ${text} ${start} ${line} {
  3778   4271   				-borderwidth -cursor -highlightbackground -highlightcolor
  3779   4272   				-highlightthickness -relief -takefocus -background
  3780   4273   				-class -colormap -container -height -visual -width
  3781   4274   			}]
  3782   4275   		}
         4276  +	}
         4277  +	return ""
         4278  +}
         4279  +
         4280  +proc complete(grab) {text start end line pos mod} {
         4281  +	switch -- ${pos} {
         4282  +		1 {
         4283  +			return [CompleteFromList ${text} [concat \
         4284  +			current release set status -global [WidgetChildren ${text}]]]
         4285  +		}
         4286  +		2 {
         4287  +			switch -- [Lindex ${line} 1] {
         4288  +				-global -
         4289  +				current -
         4290  +				release -
         4291  +				status {
         4292  +					return [CompleteFromList ${text} [WidgetChildren ${text}]]
         4293  +				}
         4294  +				set {
         4295  +					return [CompleteFromList ${text} \
         4296  +					[concat -global [WidgetChildren ${text}]]]
         4297  +				}
         4298  +			}
         4299  +		}
         4300  +		3 {
         4301  +			switch -- [Lindex ${line} 1] {
         4302  +				set {
         4303  +					switch -- [PreviousWord ${start} ${line}] {
         4304  +						-global {
         4305  +							return [CompleteFromList ${text} \
         4306  +							[WidgetChildren ${text}]]
         4307  +						}
         4308  +					}
         4309  +				}
         4310  +			}
         4311  +		}
         4312  +	}
         4313  +	return ""
         4314  +}
         4315  +
         4316  +proc GridConfig {text start line prev} {
         4317  +	set opts {
         4318  +		-column -columnspan -in -ipadx -ipady
         4319  +		-padx -pady -row -rowspan -sticky
         4320  +	}
         4321  +	if {-1 == [string first "-" ${line}]} {
         4322  +		set slave [WidgetChildren ${text}]
         4323  +	} else {
         4324  +		set slave ""
         4325  +	}
         4326  +	switch -- ${prev} {
         4327  +		-column -
         4328  +		-columnspan -
         4329  +		-row -
         4330  +		-rowspan { return [DisplayHints <n>] }
         4331  +
         4332  +		-ipadx -
         4333  +		-ipady -
         4334  +		-padx -
         4335  +		-pady { return [DisplayHints <amount>] }
         4336  +
         4337  +		-in { return [CompleteFromList ${text} [WidgetChildren ${text}]] }
         4338  +		-sticky {
         4339  +			set prev [PreviousWordOfIncompletePosition ${start} ${line}]
         4340  +			return [CompleteListFromList ${text} \
         4341  +			[string trimleft [IncompleteListRemainder ${line}]] \
         4342  +			{n e s w} \{ { } \}]
         4343  +		}
         4344  +
         4345  +
         4346  +		default {
         4347  +			return [CompleteFromList ${text} \
         4348  +			[RemoveUsedOptions ${line} [concat ${opts} ${slave}]]]
         4349  +		}
         4350  +	}
         4351  +}
         4352  + 
         4353  +proc complete(grid) {text start end line pos mod} {
         4354  +	set sub [Lindex ${line} 1]
         4355  +	set prev [PreviousWord ${start} ${line}]
         4356  +	switch -- ${pos} {
         4357  +		1 {
         4358  +			return [CompleteFromList ${text} \
         4359  +			[concat [WidgetChildren ${text}] {
         4360  +				bbox columnconfigure configure forget
         4361  +				info location propagate rowconfigure
         4362  +				remove size slaves
         4363  +			}]]
         4364  +		}
         4365  +		2 {
         4366  +			switch -- ${sub} {
         4367  +				bbox -
         4368  +				columnconfigure -
         4369  +				configure -
         4370  +				forget -
         4371  +				info -
         4372  +				location -
         4373  +				propagate -
         4374  +				rowconfigure -
         4375  +				remove -
         4376  +				size -
         4377  +				slaves {
         4378  +					return [CompleteFromList ${text} [WidgetChildren ${text}]]
         4379  +				}
         4380  +				default {
         4381  +					return [GridConfig ${text} ${start} ${line} ${prev}]
         4382  +				}
         4383  +			}
         4384  +		}
         4385  +		default {
         4386  +			switch -- ${sub} {
         4387  +				bbox {
         4388  +					switch [expr ${pos} % 2] {
         4389  +						0 { return [DisplayHints ?row?] }
         4390  +						1 { return [DisplayHints ?column?] }
         4391  +					}
         4392  +				}
         4393  +				rowconfigure -
         4394  +				columnconfigure {
         4395  +					switch -- ${pos} {
         4396  +						3 { return [DisplayHints <index>] }
         4397  +						default {
         4398  +							switch -- ${prev} {
         4399  +								-minsize { return [DisplayHints <minsize>] }
         4400  +								-weight { return [DisplayHints <weight>] }
         4401  +								-pad { return [DisplayHints <pad>] }
         4402  +								default {
         4403  +									return [CompleteFromList ${text} \
         4404  +									[RemoveUsedOptions ${line}  {
         4405  +										-minsize -weight -pad
         4406  +									}]]
         4407  +								}
         4408  +							}
         4409  +						}
         4410  +					}
         4411  +				}
         4412  +				configure {
         4413  +					return [GridConfig ${text} ${start} ${line} ${prev}]
         4414  +				}
         4415  +				forget -
         4416  +				remove {
         4417  +					return [CompleteFromList ${text} [WidgetChildren ${text}]]
         4418  +				}
         4419  +				info {}
         4420  +				location {
         4421  +					switch -- ${pos} {
         4422  +						3 { return [DisplayHints <x>] }
         4423  +						4 { return [DisplayHints <y>] }
         4424  +					}
         4425  +				}
         4426  +				propagate {
         4427  +					switch -- ${pos} {
         4428  +						3 { return [CompleteBoolean ${text}] }
         4429  +					}
         4430  +				}
         4431  +				size {}
         4432  +				slaves {
         4433  +					switch -- ${prev} {
         4434  +						-row { return [DisplayHints <row>] }
         4435  +						-column { return [DisplayHints <column>] }
         4436  +						default {
         4437  +							return [CompleteFromList ${text} \
         4438  +							[RemoveUsedOptions ${line}  { -row -column }]]
         4439  +						}
         4440  +					}
         4441  +				}
         4442  +				default {
         4443  +					return [GridConfig ${text} ${start} ${line} ${prev}]
         4444  +				}
         4445  +			}
         4446  +		}
  3783   4447   	}
  3784   4448   	return ""
  3785   4449   }
  3786   4450   
  3787   4451   proc complete(image) {text start end line pos mod} {
  3788   4452   set sub [Lindex ${line} 1]
  3789   4453   	switch -- ${pos} {
................................................................................
  3904   4568   				-width -xscrollcommand -yscrollcommand -height -selectmode
  3905   4569   				-width
  3906   4570   			}]
  3907   4571   		}
  3908   4572   	}
  3909   4573   	return ""
  3910   4574   }
         4575  +
         4576  +proc complete(lower) {text start end line pos mod} {
         4577  +	switch -- ${pos} {
         4578  +		1 -
         4579  +		2 {
         4580  +			return [CompleteFromList ${text} [WidgetChildren ${text}]]
         4581  +		}
         4582  +	}
         4583  +}
  3911   4584   
  3912   4585   proc complete(menu) {text start end line pos mod} {
  3913   4586   	switch -- ${pos} {
  3914   4587   		1 { return [EventuallyInsertLeadingDot ${text} <pathName>] }
  3915   4588   		default {
  3916   4589   			return [CompleteWidgetConfigurations ${text} ${start} ${line} {
  3917   4590   				-activebackground -activeborderwidth -activeforeground
................................................................................
  3951   4624   				-padx -pady -relief -takefocus -text -textvariable -width 
  3952   4625   				-aspect -justify -width
  3953   4626   			}]
  3954   4627   		}
  3955   4628   	}
  3956   4629   	return ""
  3957   4630   }
         4631  +
         4632  +proc OptionPriority text {
         4633  +	return [CompleteFromList ${text} {
         4634  +		widgetDefault startupFile userDefault interactive
         4635  +	}]
         4636  +}
         4637  +
         4638  +proc complete(option) {text start end line pos mod} {
         4639  +	set sub [Lindex ${line} 1]
         4640  +	switch -- ${pos} {
         4641  +		1 {
         4642  +			return [CompleteFromList ${text} {
         4643  +				add clear get readfile
         4644  +			}]
         4645  +		}
         4646  +		2 {
         4647  +			switch -- ${sub} {
         4648  +				add { return [DisplayHints <pattern>] }
         4649  +				get {
         4650  +					return [CompleteFromList ${text} [WidgetChildren ${text}]]
         4651  +				}
         4652  +				readfile { return "" }
         4653  +			}
         4654  +		}
         4655  +		3 {
         4656  +			switch -- ${sub} {
         4657  +				add { return [DisplayHints <value>] }
         4658  +				get { return [DisplayHints <name>] }
         4659  +				readfile { return [OptionPriority ${text}] }
         4660  +			}
         4661  +		}
         4662  +		4 {
         4663  +			switch -- ${sub} {
         4664  +				add { return [OptionPriority ${text}] }
         4665  +				get {
         4666  +					return [CompleteFromList ${text} \
         4667  +					[ClassTable [Lindex ${line} 2]]]
         4668  +				}
         4669  +				readfile {}
         4670  +			}
         4671  +		}
         4672  +	}
         4673  +}
         4674  +
         4675  +proc PackConfig {text line prev} {
         4676  +	set opts {
         4677  +		-after -anchor -before -expand -fill
         4678  +		-in -ipadx -ipady -padx -pady -side
         4679  +	}
         4680  +	if {-1 == [string first "-" ${line}]} {
         4681  +		set slave [WidgetChildren ${text}]
         4682  +	} else {
         4683  +		set slave ""
         4684  +	}
         4685  +	switch -- ${prev} {
         4686  +		-after -
         4687  +		-before  { return [CompleteFromList ${text} [WidgetChildren ${text}]] }
         4688  +		-anchor { return [CompleteAnchor ${text}] }
         4689  +		-expand { return [CompleteBoolean ${text}] }
         4690  +		-fill { return [CompleteFromList ${text} { none x y both }] }
         4691  +
         4692  +		-ipadx -
         4693  +		-ipady -
         4694  +		-padx -
         4695  +		-pady { return [DisplayHints <amount>] }
         4696  +
         4697  +		-in { return [CompleteFromList ${text} [WidgetChildren ${text}]] }
         4698  +		-side { return [CompleteFromList ${text} { left right top bottom }] }
         4699  +
         4700  +		default {
         4701  +			return [CompleteFromList ${text} \
         4702  +			[RemoveUsedOptions ${line} [concat ${opts} ${slave}]]]
         4703  +		}
         4704  +	}
         4705  +}
         4706  +
         4707  +proc complete(pack) {text start end line pos mod} {
         4708  +	set sub [Lindex ${line} 1]
         4709  +	set prev [PreviousWord ${start} ${line}]
         4710  +	switch -- ${pos} {
         4711  +		1 {
         4712  +			return [CompleteFromList ${text} \
         4713  +			[concat [WidgetChildren ${text}] {
         4714  +				configure forget info propagate slaves
         4715  +			}]]
         4716  +		}
         4717  +		2 {
         4718  +			switch -- ${sub} {
         4719  +				configure -
         4720  +				forget -
         4721  +				info -
         4722  +				propagate -
         4723  +				slaves {
         4724  +					return [CompleteFromList ${text} [WidgetChildren ${text}]]
         4725  +				}
         4726  +				default {
         4727  +					return [PackConfig ${text} ${line} ${prev}]
         4728  +				}
         4729  +			}
         4730  +		}
         4731  +		default {
         4732  +			switch -- ${sub} {
         4733  +				configure {
         4734  +					return [PackConfig ${text} ${line} ${prev}]
         4735  +				}
         4736  +				forget {
         4737  +					return [CompleteFromList ${text} [WidgetChildren ${text}]]
         4738  +				}
         4739  +				info {}
         4740  +				propagate {
         4741  +					switch -- ${pos} {
         4742  +						3 { return [CompleteBoolean ${text}] }
         4743  +					}
         4744  +				}
         4745  +				slaves {}
         4746  +				default {
         4747  +					return [PackConfig ${text} ${line} ${prev}]
         4748  +				}
         4749  +			}
         4750  +		}
         4751  +	}
         4752  +	return ""
         4753  +}
  3958   4754   
  3959   4755   proc complete(radiobutton) {text start end line pos mod} {
  3960   4756   	switch -- ${pos} {
  3961   4757   		1 { return [EventuallyInsertLeadingDot ${text} <pathName>] }
  3962   4758   		default {
  3963   4759   			return [CompleteWidgetConfigurations ${text} ${start} ${line} {
  3964   4760   				-activebackground -activeforeground -anchor -background
................................................................................
  3969   4765   				-height -indicatoron -selectcolor -selectimage -state -value
  3970   4766   				-variable -width
  3971   4767   			}]
  3972   4768   		}
  3973   4769   	}
  3974   4770   	return ""
  3975   4771   }
         4772  +
         4773  +proc complete(raise) {text start end line pos mod} {
         4774  +	return [complete(lower) ${text} ${start} ${end} ${line} ${pos} ${mod}]
         4775  +}
  3976   4776   
  3977   4777   proc complete(scale) {text start end line pos mod} {
  3978   4778   	switch -- ${pos} {
  3979   4779   		1 { return [EventuallyInsertLeadingDot ${text} <pathName>] }
  3980   4780   		default {
  3981   4781   			return [CompleteWidgetConfigurations ${text} ${start} ${line} {
  3982   4782   				-activebackground -background -borderwidth -cursor -font
................................................................................
  4292   5092   						-anchor -height -tags -width -window
  4293   5093   					}]]
  4294   5094   				}
  4295   5095   			}
  4296   5096   		}
  4297   5097   	}
  4298   5098   }
         5099  +
         5100  +#**
         5101  +# WidgetXviewYview
         5102  +# 
         5103  +# @param    text  -- the word to complete.
         5104  +# @param    line  -- the line gathered so far.
         5105  +# @param    pos   -- the current word position.
         5106  +# @param    prev  -- the previous word.
         5107  +# @return   a std tclreadline formatted completer string.
         5108  +# @sa       CanvasObj, EntryObj
         5109  +# @date     Sep-18-1999
         5110  +#
         5111  +proc WidgetXviewYview {text line pos prev} {
         5112  +	switch -- ${pos} {
         5113  +		2 { return [CompleteFromList ${text} {<index> moveto scroll}] }
         5114  +		3 {
         5115  +			switch -- ${prev} {
         5116  +				moveto { return [DisplayHints <fraction>] }
         5117  +				scroll { return [DisplayHints <number>] }
         5118  +			}
         5119  +		}
         5120  +		4 {
         5121  +			set subcmd [Lindex ${line} 2]
         5122  +			switch -- ${subcmd} {
         5123  +				scroll { return [DisplayHints <what>] }
         5124  +			}
         5125  +		}
         5126  +	}
         5127  +}
         5128  +
         5129  +#**
         5130  +# WidgetScan
         5131  +# 
         5132  +# @param    text  -- the word to complete.
         5133  +# @param    pos   -- the current word position.
         5134  +# @return   a std tclreadline formatted completer string.
         5135  +# @sa       CanvasObj, EntryObj
         5136  +# @date     Sep-18-1999
         5137  +#
         5138  +proc WidgetScan {text pos} {
         5139  +	switch -- ${pos} {
         5140  +		2 { return [CompleteFromList ${text} {mark dragto}] }
         5141  +		3 { return [DisplayHints <x>] }
         5142  +		4 { return [DisplayHints <y>] }
         5143  +	}
         5144  +}
  4299   5145   
  4300   5146   proc CanvasObj {text start end line pos} {
  4301   5147   	set sub [Lindex ${line} 1]
  4302   5148   	set prev [PreviousWord ${start} ${line}]
  4303   5149   	if {1 == $pos} {
  4304         -		return; # let the fallback routines do the job.
         5150  +		return ""; # let the fallback routines do the job.
  4305   5151   	}
  4306   5152   	switch -- ${sub} {
  4307   5153   		addtag {
  4308   5154   			switch -- ${pos} {
  4309   5155   				2 { return [DisplayHints <tag>] }
  4310   5156   				3 {
  4311   5157   					return [CompleteFromList ${text} {
................................................................................
  4475   5321   				2 { return [DisplayHints <tagOrId>] }
  4476   5322   				3 { return [DisplayHints <xOrigin>] }
  4477   5323   				4 { return [DisplayHints <yOrigin>] }
  4478   5324   				5 { return [DisplayHints <xScale>] }
  4479   5325   				6 { return [DisplayHints <yScale>] }
  4480   5326   			}
  4481   5327   		}
  4482         -		scan {
  4483         -			switch -- ${pos} {
  4484         -				2 { return [CompleteFromList ${text} {mark dragto}] }
  4485         -				3 { return [DisplayHints <x>] }
  4486         -				4 { return [DisplayHints <y>] }
  4487         -			}
  4488         -		}
         5328  +		scan { return [WidgetScan ${text} ${pos}] }
  4489   5329   		select {
  4490   5330   			switch -- ${pos} {
  4491   5331   				2 {
  4492   5332   					return [CompleteFromList ${text} {
  4493   5333   						adjust clear item from to
  4494   5334   					}]
  4495   5335   				}
................................................................................
  4508   5348   						from -
  4509   5349   						to { return [DisplayHints <index>] }
  4510   5350   					}
  4511   5351   				}
  4512   5352   			}
  4513   5353   		}
  4514   5354   		xview -
  4515         -		yview {
  4516         -			switch -- ${pos} {
  4517         -				2 { return [CompleteFromList ${text} {moveto scroll}] }
  4518         -				3 {
  4519         -					switch -- ${prev} {
  4520         -						moveto { return [DisplayHints <fraction>] }
  4521         -						scroll { return [DisplayHints <number>] }
  4522         -					}
  4523         -				}
  4524         -				4 {
  4525         -					set subcmd [Lindex ${line} 2]
  4526         -					switch -- ${subcmd} {
  4527         -						scroll { return [DisplayHints <what>] }
  4528         -					}
  4529         -				}
  4530         -			}
  4531         -		}
         5355  +		yview { return [XviewYview ${text} ${line} ${pos} ${prev}] }
  4532   5356   		create {
  4533   5357   			switch -- ${pos} {
  4534   5358   				2 {
  4535   5359   					return [CompleteFromList ${text} {
  4536   5360   						arc bitmap image line oval
  4537   5361   						polygon rectangle text window
  4538   5362   					}]
................................................................................
  4589   5413   					${end} ${line} ${pos} ${prev} ${type}]
  4590   5414   				}
  4591   5415   			}
  4592   5416   		}
  4593   5417   	}
  4594   5418   	return ""
  4595   5419   }
         5420  +
         5421  +proc EntryIndex text {
         5422  +	return [CompleteFromList ${text} {
         5423  +		<number> <@number> anchor end sel.first sel.last
         5424  +	}]
         5425  +}
  4596   5426   
  4597   5427   proc EntryObj {text start end line pos} {
  4598   5428   	set sub [Lindex ${line} 1]
  4599   5429   	set prev [PreviousWord ${start} ${line}]
  4600   5430   	if {1 == $pos} {
  4601         -		return; # let the fallback routines do the job.
         5431  +		return ""; # let the fallback routines do the job.
  4602   5432   	}
  4603   5433   	switch -- ${sub} {
  4604         -		bbox {}
         5434  +		bbox -
         5435  +		icursor -
         5436  +		index { return [EntryIndex ${text}] }
  4605   5437   		cget {}
  4606   5438   		configure {}
  4607         -		delete {}
  4608   5439   		get {}
  4609         -		icursor {}
  4610         -		index {}
  4611         -		insert {}
  4612         -		scan {
         5440  +		insert {
         5441  +			switch -- ${pos} {
         5442  +				2 { return [EntryIndex ${text}] }
         5443  +				3 { return [DisplayHints <string>] }
         5444  +			}
         5445  +		}
         5446  +		scan { return [WidgetScan ${text} ${pos}] }
         5447  +		selection {
  4613   5448   			switch -- ${pos} {
  4614         -				2 { return [CompleteFromList ${text} {mark dragto}] }
  4615         -				3 { return [DisplayHints <x>] }
  4616         -				4 { return [DisplayHints <y>] }
  4617         -			}
  4618         -		}
  4619         -		selection {}
  4620         -		xview -
  4621         -		yview {
  4622         -			switch -- ${pos} {
  4623         -				2 { return [CompleteFromList ${text} {moveto scroll}] }
         5449  +				# let the fallback routines do the job.
         5450  +				2 { return "" }
  4624   5451   				3 {
  4625   5452   					switch -- ${prev} {
  4626         -						moveto { return [DisplayHints <fraction>] }
  4627         -						scroll { return [DisplayHints <number>] }
         5453  +						adjust -
         5454  +						from -
         5455  +						to { return [EntryIndex ${text}] }
         5456  +						clear -
         5457  +						present {}
         5458  +						range { return [DisplayHints <start>] }
  4628   5459   					}
  4629   5460   				}
  4630   5461   				4 {
  4631         -					set subcmd [Lindex ${line} 2]
  4632         -					switch -- ${subcmd} {
  4633         -						scroll { return [DisplayHints <what>] }
         5462  +					switch -- [Lindex ${line} 2] {
         5463  +						range { return [DisplayHints <end>] }
  4634   5464   					}
  4635   5465   				}
  4636   5466   			}
  4637   5467   		}
         5468  +		xview -
         5469  +		yview { return [WidgetXviewYview ${text} ${line} ${pos} ${prev}] }
  4638   5470   	}
  4639   5471   	return ""
  4640   5472   }
  4641   5473   
  4642   5474   # proc CheckbuttonObj {text start end line pos} {
         5475  +# the fallback routines do the job pretty well.
  4643   5476   # }
  4644   5477   
  4645   5478   # proc FrameObj {text start end line pos} {
  4646         -# 	return ""
         5479  +# the fallback routines do the job pretty well.
         5480  +# }
         5481  +
         5482  +# proc LabelObj {text start end line pos} {
         5483  +# the fallback routines do the job pretty well.
  4647   5484   # }
         5485  +
         5486  +proc ListboxObj {text start end line pos} {
         5487  +	set sub [Lindex ${line} 1]
         5488  +	set prev [PreviousWord ${start} ${line}]
         5489  +	if {1 == $pos} {
         5490  +		return ""; # let the fallback routines do the job.
         5491  +	}
         5492  +	switch -- ${sub} {
         5493  +		activate -
         5494  +		bbox -
         5495  +		index -
         5496  +		see {
         5497  +			switch -- ${pos} {
         5498  +				2 {
         5499  +					return [DisplayHints <index>]
         5500  +				}
         5501  +			}
         5502  +		}
         5503  +		insert {
         5504  +			switch -- ${pos} {
         5505  +				2 {
         5506  +					return [DisplayHints <index>]
         5507  +				}
         5508  +				default {
         5509  +					return [DisplayHints ?element?]
         5510  +				}
         5511  +			}
         5512  +		}
         5513  +		cget {}
         5514  +		configure {}
         5515  +		curselection {}
         5516  +		delete -
         5517  +		get {
         5518  +			switch -- ${pos} {
         5519  +				2 {
         5520  +					return [DisplayHints <first>]
         5521  +				}
         5522  +				3 {
         5523  +					return [DisplayHints ?last?]
         5524  +				}
         5525  +			}
         5526  +		}
         5527  +		nearest {
         5528  +			switch -- ${pos} {
         5529  +				2 {
         5530  +					return [DisplayHints <y>]
         5531  +				}
         5532  +			}
         5533  +		}
         5534  +		size {}     
         5535  +
         5536  +		scan { return [WidgetScan ${text} ${pos}] }
         5537  +
         5538  +		xview -
         5539  +		yview { return [WidgetXviewYview ${text} ${line} ${pos} ${prev}] }
         5540  +
         5541  +		selection {
         5542  +			switch -- ${pos} {
         5543  +				2 {
         5544  +					return [CompleteFromList ${text} \
         5545  +					{anchor clear includes set}]
         5546  +				}
         5547  +				3 {
         5548  +					switch -- ${prev} {
         5549  +						anchor -
         5550  +						includes {
         5551  +							return [CompleteFromList ${text} {
         5552  +								active anchor end @x @y <number>
         5553  +							}]
         5554  +						}
         5555  +						clear -
         5556  +						set { return [DisplayHints <first>] }
         5557  +					}
         5558  +				}
         5559  +				4 {
         5560  +					switch -- [Lindex ${line} 2] {
         5561  +						clear -
         5562  +						set { return [DisplayHints ?last?] }
         5563  +					}
         5564  +				}
         5565  +			}
         5566  +		}
         5567  +	}
         5568  +}
         5569  +
         5570  +proc MenuIndex text {
         5571  +	return [CompleteFromList ${text} {
         5572  +		<number> active end last none <@number> <labelPattern>
         5573  +	}]
         5574  +}
         5575  +
         5576  +proc MenuItem {text start end line pos virtualpos} {
         5577  +	switch -- ${virtualpos} {
         5578  +		2 {
         5579  +			return [CompleteFromList ${text} {
         5580  +				cascade checkbutton command radiobutton separator
         5581  +			}]
         5582  +		}
         5583  +		default {
         5584  +			switch -- [PreviousWord ${start} ${line}] {
         5585  +				-activebackground -
         5586  +				-activeforeground -
         5587  +				-background -
         5588  +				-foreground -
         5589  +				-selectcolor {
         5590  +					return [DisplayHints <color>]
         5591  +				}
         5592  +
         5593  +				-accelerator { return [DisplayHints <accel>] }
         5594  +				-bitmap { return [CompleteFromBitmaps ${text}] }
         5595  +
         5596  +				-columnbreak -
         5597  +				-hidemargin -
         5598  +				-indicatoron {
         5599  +					return [CompleteBoolean ${text}]
         5600  +				}
         5601  +				-command {
         5602  +					return [BraceOrCommand ${text} \
         5603  +					${start} ${end} ${line} ${pos} ${text}]
         5604  +				}
         5605  +				-font {
         5606  +					set names [font names]
         5607  +					if {[string length ${names}]} {
         5608  +						return [CompleteFromList ${text} ${names}]
         5609  +					} else {
         5610  +						return [DisplayHints <fontname>]
         5611  +					}
         5612  +				}
         5613  +				-image -
         5614  +				-selectimage {
         5615  +					set names [image names]
         5616  +					if {[string length ${names}]} {
         5617  +						return [CompleteFromList ${text} ${names}]
         5618  +					} else {
         5619  +						return [DisplayHints <image>]
         5620  +					}
         5621  +				}
         5622  +
         5623  +				-label { return [DisplayHints <label>] }
         5624  +				-menu {
         5625  +					set names [WidgetChildren [Lindex ${line} 0]]
         5626  +					if {[string length ${names}]} {
         5627  +						return [CompleteFromList ${text} ${names}]
         5628  +					} else {
         5629  +						return [DisplayHints <menu>]
         5630  +					}
         5631  +				}
         5632  +
         5633  +				-offvalue -
         5634  +				-onvalue { return [DisplayHints <value>] }
         5635  +
         5636  +				-state {
         5637  +					return [CompleteFromList ${text} {
         5638  +						normal active disabled
         5639  +					}]
         5640  +				}
         5641  +				-underline { return [DisplayHints <integer>] }
         5642  +				-value { return [DisplayHints <value>] }
         5643  +				-variable {
         5644  +					return [VarCompletion ${text} #0]
         5645  +				}
         5646  +
         5647  +				default {
         5648  +					return [CompleteFromList ${text} \
         5649  +					[RemoveUsedOptions ${line} {
         5650  +						-activebackground -activeforeground
         5651  +						-accelerator -background -bitmap -columnbreak
         5652  +						-command -font -foreground -hidemargin -image
         5653  +						-indicatoron -label -menu -offvalue -onvalue
         5654  +						-selectcolor -selectimage -state -underline
         5655  +						-value -variable
         5656  +					}]]
         5657  +				}
         5658  +			}
         5659  +		}
         5660  +	}
         5661  +}
         5662  +
         5663  +proc MenuObj {text start end line pos} {
         5664  +	set sub [Lindex ${line} 1]
         5665  +	set prev [PreviousWord ${start} ${line}]
         5666  +	if {1 == $pos} {
         5667  +		return ""; # let the fallback routines do the job.
         5668  +	}
         5669  +	switch -- ${sub} {
         5670  +		activate -
         5671  +		index -
         5672  +		invoke -
         5673  +		postcascade -
         5674  +		type -
         5675  +		yposition {
         5676  +			switch -- ${pos} {
         5677  +				2 {
         5678  +					return [MenuIndex ${text}]
         5679  +				}
         5680  +			}
         5681  +		}
         5682  +		configure {}
         5683  +		cget {}
         5684  +
         5685  +		add {
         5686  +			return [MenuItem ${text} ${start} ${end} ${line} ${pos} ${pos}]
         5687  +		}
         5688  +		clone {
         5689  +			switch -- ${pos} {
         5690  +				2 { return [DisplayHints <newPathname>] }
         5691  +				3 {
         5692  +					return [CompleteFromList ${text} {
         5693  +						normal menubar tearoff
         5694  +					}]
         5695  +				}
         5696  +			}
         5697  +		}
         5698  +		delete {
         5699  +			switch -- ${pos} {
         5700  +				2 -
         5701  +				3 { return [MenuIndex ${text}] }
         5702  +			}
         5703  +		}
         5704  +		insert {
         5705  +			switch -- ${pos} {
         5706  +				2 { return [MenuIndex ${text}] }
         5707  +				default {
         5708  +					return [MenuItem ${text} ${start} ${end} \
         5709  +					${line} ${pos} [expr ${pos} - 1]]
         5710  +				}
         5711  +			}
         5712  +		}
         5713  +		entrycget -
         5714  +		entryconfigure {
         5715  +			switch -- ${pos} {
         5716  +				2 { return [MenuIndex ${text}] }
         5717  +				default {
         5718  +					return [MenuItem ${text} ${start} \
         5719  +					${end} ${line} ${pos} ${pos}]
         5720  +				}
         5721  +			}
         5722  +		}
         5723  +		post {
         5724  +			switch -- ${pos} {
         5725  +				2 { return [DisplayHints <x>] }
         5726  +				3 { return [DisplayHints <y>] }
         5727  +			}
         5728  +		}
         5729  +		# ??? XXX
         5730  +		unpost {}
         5731  +	}
         5732  +}
  4648   5733   
  4649   5734   }; # namespace tclreadline