No registered users in community xowiki
in last 10 minutes
in last 10 minutes
Re: [Xotcl] Request for XOTcl proc and var type ahead in tkcon
From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Wed, 06 Apr 2005 14:12:07 +0200
Hi John and Jeff,
Just now i made a quick attempt to handle all kind of methods in
tkcon.tcl (i started with
the newest version from the cvs repository http://tkcon.sourceforge.net/).
The code tgries to be least invasive, there are almost certainly more
elegant
ways to handle this, however, it seems to work pretty well with procs,
instprocs
(as well with instprocs from mixins). See the following script, where i
have added the
lines with the <TAB> keys.
=======
(scripts) 4 % package require XOTcl
1.3.6
(scripts) 5 % namespace import ::xotcl::*
(scripts) 6 % Class create M -instproc foo {} {puts hi}
::M
(scripts) 7 % Object o
::o
(scripts) 8 % o set<TAB>
self set
(scripts) 8 % o set x 1
1
(scripts) 9 % o mixin M
foo forward
(scripts) 10 % o fo<TAB>
=======
just replace ::tkcon::ExpandProcname with the proc below.
Jeff, I am not too happy about the way expandOrder is evaluated,
but this might be a misleading impression of a new user. frequently,
the expansion of pathnames overrules the proc expansion. how about
doing the pathname expansion (optionally) when the path starts with
one of "./~"?
all the best
-gustaf
=====================================================
proc ::tkcon::ExpandProcname str {
# in a first step, get the cmd to check, if we should handle subcommands
set cmd [::tkcon::CmdGet $::tkcon::PRIV(console)]
# if there are two cmds, and xotcl is loaded, do the xotcl magic
if {[llength $cmd]==2 &&
[EvalAttached [list info exists ::xotcl::version]]} {
set o [lindex $cmd 0]
set sub [lindex $cmd 1]
set match [EvalAttached [list $o info methods $sub*]]
} else {
# standard behavior
set match [EvalAttached [list info commands $str*]]
if {[llength $match] == 0} {
set ns [EvalAttached \
"namespace children \[namespace current\] [list $str*]"]
if {[llength $ns]==1} {
set match [EvalAttached [list info commands ${ns}::*]]
} else {
set match $ns
}
}
}
if {[llength $match] > 1} {
regsub -all {([^\\]) } [ExpandBestMatch $match $str] {\1\\ } str
set match [linsert $match 0 $str]
} else {
regsub -all {([^\\]) } $match {\1\\ } match
}
return $match
}
=====================================================
Date: Wed, 06 Apr 2005 14:12:07 +0200
Hi John and Jeff,
Just now i made a quick attempt to handle all kind of methods in
tkcon.tcl (i started with
the newest version from the cvs repository http://tkcon.sourceforge.net/).
The code tgries to be least invasive, there are almost certainly more
elegant
ways to handle this, however, it seems to work pretty well with procs,
instprocs
(as well with instprocs from mixins). See the following script, where i
have added the
lines with the <TAB> keys.
=======
(scripts) 4 % package require XOTcl
1.3.6
(scripts) 5 % namespace import ::xotcl::*
(scripts) 6 % Class create M -instproc foo {} {puts hi}
::M
(scripts) 7 % Object o
::o
(scripts) 8 % o set<TAB>
self set
(scripts) 8 % o set x 1
1
(scripts) 9 % o mixin M
foo forward
(scripts) 10 % o fo<TAB>
=======
just replace ::tkcon::ExpandProcname with the proc below.
Jeff, I am not too happy about the way expandOrder is evaluated,
but this might be a misleading impression of a new user. frequently,
the expansion of pathnames overrules the proc expansion. how about
doing the pathname expansion (optionally) when the path starts with
one of "./~"?
all the best
-gustaf
=====================================================
proc ::tkcon::ExpandProcname str {
# in a first step, get the cmd to check, if we should handle subcommands
set cmd [::tkcon::CmdGet $::tkcon::PRIV(console)]
# if there are two cmds, and xotcl is loaded, do the xotcl magic
if {[llength $cmd]==2 &&
[EvalAttached [list info exists ::xotcl::version]]} {
set o [lindex $cmd 0]
set sub [lindex $cmd 1]
set match [EvalAttached [list $o info methods $sub*]]
} else {
# standard behavior
set match [EvalAttached [list info commands $str*]]
if {[llength $match] == 0} {
set ns [EvalAttached \
"namespace children \[namespace current\] [list $str*]"]
if {[llength $ns]==1} {
set match [EvalAttached [list info commands ${ns}::*]]
} else {
set match $ns
}
}
}
if {[llength $match] > 1} {
regsub -all {([^\\]) } [ExpandBestMatch $match $str] {\1\\ } str
set match [linsert $match 0 $str]
} else {
regsub -all {([^\\]) } $match {\1\\ } match
}
return $match
}
=====================================================