Check-in [a7cb82dbde]
Not logged in
Overview
Comment: 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
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:a7cb82dbde9350c31ae885487afe64f7de9a6c7b
User & Date: johannes@zellner.org on 1999-09-19 21:18:23
Other Links: manifest | tags
Context
1999-09-19
23:17
src/tclreadline/Makefile.in src/tclreadline/README src/tclreadline/configure.in check-in: 80e099e981 user: johannes@zellner.org tags: trunk
21:18
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 check-in: a7cb82dbde user: johannes@zellner.org tags: trunk
10:48
share/vim/ft/tcl_ft.vim src/tclreadline/tclreadlineCompleter.tcl check-in: f06e7a16c7 user: johannes@zellner.org tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Modified README from [526d06c650] to [f6e3ce53eb].

     1      1   
     2      2       FILE: "/home/joze/src/tclreadline/README"
     3         -    LAST MODIFICATION: "Thu Sep 16 20:02:57 1999 (joze)"
            3  +    LAST MODIFICATION: "Sun Sep 19 22:44:24 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   
................................................................................
    73     73   start your favorite interpreter. The tclreadlineSetup.tcl script
    74     74   does the rest.
    75     75   
    76     76   
    77     77   4. History and Changes.
    78     78   -----------------------
    79     79   
           80  +tclreadline-1.0.0: (Sep 1999)
           81  +
           82  +	note:
           83  +	    - the script completer procs are written.
           84  +		  this is `sort of a first usable release'.
           85  +
    80     86   
    81     87   tclreadline-0.9.3: (Sep 1999)
    82     88   
    83     89       changes:
    84     90   	    - tk completion.
    85     91   		- multiple fallback completion routines for unknown
    86     92   		  commands.

Modified configure.in from [19e43b3702] to [0c9810d5e7].

     1      1   # -*- autoconf -*-
     2         -# FILE: "/disk01/home/joze/src/tclreadline/configure.in"
     3         -# LAST MODIFICATION: "Tue Sep 14 11:23:46 1999 (joze)"
            2  +# FILE: "/home/joze/src/tclreadline/configure.in"
            3  +# LAST MODIFICATION: "Sun Sep 19 23:15:53 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   #
................................................................................
    32     32   dnl	to configure the system for the local environment.
    33     33   
    34     34   AC_REVISION($Revision$)
    35     35   
    36     36   AC_INIT(tclreadline.c)
    37     37   AC_CONFIG_HEADER(config.h)
    38     38   
    39         -TCLREADLINE_MAJOR_VERSION=0
    40         -TCLREADLINE_MINOR_VERSION=9
    41         -TCLREADLINE_PATCHLEVEL=3
           39  +TCLREADLINE_MAJOR_VERSION=1
           40  +TCLREADLINE_MINOR_VERSION=0
           41  +TCLREADLINE_PATCHLEVEL=0
    42     42   TCLREADLINE_VERSION=$TCLREADLINE_MAJOR_VERSION.$TCLREADLINE_MINOR_VERSION
    43     43   TCLREADLINE_PATCHLEVEL_STR=${TCLREADLINE_VERSION}.${TCLREADLINE_PATCHLEVEL}
    44     44   VERSION=$TCLREADLINE_VERSION
    45     45   
    46     46   
    47     47   AC_PREREQ(2.13)
    48     48   AC_CONFIG_AUX_DIR(./aux)
................................................................................
   341    341   else
   342    342       AC_MSG_RESULT(${READLINE_LIB_DIR}/libreadline${SHLIB_SUFFIX}${READLINE_VERSION_SUFFIX})
   343    343   fi
   344    344   
   345    345   
   346    346   
   347    347   # ---
   348         -# check, if curses or termcap is already
   349         -# linked with libreadline. (on newer Linux
   350         -# systems it is.)
          348  +# check for the terminal library.
          349  +# This part was shamelessly stolen from
          350  +# the vim-5.5 configure.in.
   351    351   # ---
   352    352   
   353         -# TERM_LIB=""
   354         -# AC_CHECK_LIB(readline, tputs, termcaps=yes, termcaps=no)
   355         -termcaps=no
   356         -if test "$termcaps" = "no"; then
   357         -
   358         -    # ---
   359         -    # nope. tputs() is unresolved in libreadline, so
   360         -    # check if we want libcurses or libtermcap.
   361         -    # ---
   362         -
   363         -    AC_ARG_WITH(
   364         -        termcap, 
   365         -        [  --with-termcap          use termcap library instead of curses.],
   366         -        TERM_LIB="termcap",
   367         -        TERM_LIB="curses"
   368         -    )
   369         -    AC_CHECK_LIB($TERM_LIB, tputs, tputs_ok=yes, tputs_ok=no)
   370         -    if test "$tputs_ok" = "no"; then
   371         -        AC_MSG_ERROR(tputs() not found in lib$TERM_LIB.)
   372         -    else
   373         -        TERM_LIB=-l$TERM_LIB
   374         -    fi
          353  +olibs="$LIBS"
          354  +AC_MSG_CHECKING(--with-tlib argument)
          355  +AC_ARG_WITH(tlib, [  --with-tlib=library     terminal library to be used ],)
          356  +if test -n "$with_tlib"; then
          357  +	AC_MSG_RESULT($with_tlib)
          358  +	LIBS="$LIBS -l$with_tlib"
          359  +else
          360  +	AC_MSG_RESULT([automatic terminal library selection])
          361  +	dnl  Newer versions of ncurses are preferred over anything.
          362  +	dnl  Older versions of ncurses have bugs, get a new one!
          363  +	dnl  Digital Unix (OSF1) should use curses (Ronald Schild).
          364  +	case "`uname -s 2>/dev/null`" in
          365  +		OSF1) tlibs="ncurses curses termlib termcap";;
          366  +		*)    tlibs="ncurses termlib termcap curses";;
          367  +	esac
          368  +	for libname in $tlibs; do
          369  +		AC_CHECK_LIB($libname, tgetent,,)
          370  +		if test "x$olibs" != "x$LIBS"; then
          371  +			dnl It's possible that a library is found but it doesn't work
          372  +			dnl e.g., shared library that cannot be found
          373  +			dnl compile and run a test program to be sure
          374  +			AC_TRY_RUN([
          375  +#ifdef HAVE_TERMCAP_H
          376  +# include <termcap.h>
          377  +#endif
          378  +main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
          379  +			res="OK", res="FAIL", res="FAIL")
          380  +			if test "$res" = "OK"; then
          381  +			  break
          382  +			fi
          383  +			AC_MSG_RESULT($libname library is not usable)
          384  +			LIBS="$olibs"
          385  +		fi
          386  +	done
          387  +fi
          388  +if test "x$olibs" != "x$LIBS"; then
          389  +	AC_MSG_CHECKING(whether we talk terminfo)
          390  +	AC_TRY_RUN([
          391  +#ifdef HAVE_TERMCAP_H
          392  +# include <termcap.h>
          393  +#endif
          394  +main()
          395  +{char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }],
          396  +	AC_MSG_RESULT([no -- we are in termcap land]),
          397  +	AC_MSG_RESULT([yes -- terminfo spoken here]); AC_DEFINE(TERMINFO),
          398  +	AC_MSG_ERROR(failed to compile test program.))
          399  +else
          400  +	AC_MSG_ERROR(none found. Please retry with the --with-tlib argument)
   375    401   fi
          402  +
          403  +AC_MSG_CHECKING(whether termcap.h contains ospeed)
          404  +AC_TRY_LINK([
          405  +#ifdef HAVE_TERMCAP_H
          406  +# include <termcap.h>
          407  +#endif
          408  +			], [ospeed = 20000],
          409  +	AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OSPEED),
          410  +	[AC_MSG_RESULT(no)
          411  +	AC_MSG_CHECKING(whether ospeed can be extern)
          412  +	AC_TRY_LINK([
          413  +#ifdef HAVE_TERMCAP_H
          414  +# include <termcap.h>
          415  +#endif
          416  +extern short ospeed;
          417  +			], [ospeed = 20000],
          418  +		AC_MSG_RESULT(yes); AC_DEFINE(OSPEED_EXTERN),
          419  +		AC_MSG_RESULT(no))]
          420  +)
          421  +
          422  +AC_MSG_CHECKING([whether termcap.h contains UP, BC and PC])
          423  +AC_TRY_LINK([
          424  +#ifdef HAVE_TERMCAP_H
          425  +# include <termcap.h>
          426  +#endif
          427  +			], [if (UP == 0 && BC == 0) PC = 1],
          428  +	AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UP_BC_PC),
          429  +	[AC_MSG_RESULT(no)
          430  +	AC_MSG_CHECKING([whether UP, BC and PC can be extern])
          431  +	AC_TRY_LINK([
          432  +#ifdef HAVE_TERMCAP_H
          433  +# include <termcap.h>
          434  +#endif
          435  +extern char *UP, *BC, PC;
          436  +			], [if (UP == 0 && BC == 0) PC = 1],
          437  +		AC_MSG_RESULT(yes); AC_DEFINE(UP_BC_PC_EXTERN),
          438  +		AC_MSG_RESULT(no))]
          439  +	)
          440  +
          441  +AC_MSG_CHECKING(whether tputs() uses outfuntype)
          442  +AC_TRY_COMPILE([
          443  +#ifdef HAVE_TERMCAP_H
          444  +# include <termcap.h>
          445  +#endif
          446  +			], [extern int xx(); tputs("test", 1, (outfuntype)xx)],
          447  +	AC_MSG_RESULT(yes); AC_DEFINE(HAVE_OUTFUNTYPE),
          448  +	AC_MSG_RESULT(no))
   376    449   
   377    450   
   378    451   #--------------------------------------------------------------------
   379    452   #   Check for appropriate version of gnu readline
   380    453   #   (older versions of gnu readline don't have
   381    454   #    rl_callback_read_char ()).
   382    455   #--------------------------------------------------------------------

Modified tclreadline.c from [035d2f38c0] to [825d7708d3].

     1      1   
     2      2    /* ==================================================================
     3      3   
     4      4       FILE: "/home/joze/src/tclreadline/tclreadline.c"
     5         -    LAST MODIFICATION: "Fri Sep 17 23:34:52 1999 (joze)"
            5  +    LAST MODIFICATION: "Sun Sep 19 22:41:52 1999 (joze)"
     6      6       (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
     7      7       $Id$
     8      8       ---
     9      9   
    10     10       tclreadline -- gnu readline for tcl
    11     11       Copyright (C) 1999  Johannes Zellner
    12     12   
................................................................................
   374    374   
   375    375           case TCLRL_RESET_TERMINAL:
   376    376   			/* TODO: add this to the completer */
   377    377               if (argc > 3) {
   378    378                   Tcl_WrongNumArgs(interp, 2, objv, "?terminal-name?");
   379    379                   return TCL_ERROR;
   380    380               } else if (3 == argc) {
   381         -				rl_reset_terminal(Tcl_GetString(objv[2]));
          381  +				/*
          382  +				 * - tcl8.0 doesn't have Tcl_GetString()
          383  +				 * - rl_reset_terminal() might be defined
          384  +				 *   to take no arguments. This might produce
          385  +				 *   a compiler warning.
          386  +				 */
          387  +				rl_reset_terminal(Tcl_GetStringFromObj(objv[2], -1));
   382    388               } else {
   383    389   				rl_cleanup_after_signal();
   384    390   			}
   385    391               break;
   386    392   
   387    393           default:
   388    394               goto BAD_COMMAND;

Modified tclreadline.n.in from [72c7fb52c1] to [d2e40c4100].

     1      1   .TH tclreadline n "@TCLREADLINE_VERSION@.@TCLREADLINE_PATCHLEVEL@" "Johannes Zellner"
     2      2   
     3      3   .\" (C) 1999 by Johannes Zellner
     4         -.\" FILE: "/disk01/home/joze/src/tclreadline/tclreadline.n.in"
     5         -.\" LAST MODIFICATION: "Thu Sep 16 18:10:41 1999 (joze)"
            4  +.\" FILE: "/home/joze/src/tclreadline/tclreadline.n.in"
            5  +.\" LAST MODIFICATION: "Sun Sep 19 21:24:19 1999 (joze)"
     6      6   .\" (C) 1998, 1999 by Johannes Zellner, <johannes@zellner.org>
     7      7   .\" $Id$
     8      8   .\" ---
     9      9   .\"
    10     10   .\" tclreadline -- gnu readline for the tcl scripting language
    11     11   .\" Copyright (C) 1999  Johannes Zellner
    12     12   .\"
................................................................................
   298    298       "\\C-xp": "puts $env(PATH)"
   299    299       $endif
   300    300   .CE
   301    301   
   302    302   For further documentation please refer to the gnu readline documentation.
   303    303   
   304    304   .SH "BUGS"
   305         -probably.
          305  +citing the readline manual:  It's too big and too slow.
   306    306   
   307    307   
   308    308   .SH "SEE ALSO"
   309    309   
   310    310   
   311    311   .PP
   312    312   The official \fBtclreadline\fP web site at:

Modified tclreadlineCompleter.tcl from [d353429a4a] to [577a853e5f].

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

Modified tclreadlineSetup.tcl.in from [d62d0c5c0c] to [3563bc89b4].

     1      1   #!/usr/locanl/bin/tclsh
     2      2   # FILE: "/home/joze/src/tclreadline/tclreadlineSetup.tcl.in"
     3         -# LAST MODIFICATION: "Thu Sep 16 20:36:37 1999 (joze)"
            3  +# LAST MODIFICATION: "Sun Sep 19 22:42:13 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   #
................................................................................
    24     24   #
    25     25   # johannes@zellner.org
    26     26   # http://www.zellner.org/tclreadline/
    27     27   #
    28     28   # ================================================================== 
    29     29   
    30     30   
    31         -# package provide tclreadline @TCLREADLINE_VERSION@
    32         -package provide tclreadline 0.9
           31  +package provide tclreadline @TCLREADLINE_VERSION@
    33     32   
    34     33   proc unknown args {
    35     34   
    36     35   	global auto_noexec auto_noload env unknown_pending tcl_interactive
    37     36   	global errorCode errorInfo
    38     37   
    39     38   	# Save the values of errorCode and errorInfo variables, since they