[REBOL] Re: keymap in text style feel/engage - where tool
From: anton::lexicon::net at: 24-Apr-2002 11:51
Great, DocKimbel!
I've been meaning to make a search tool like this
for a while, but too busy with other stuff.
> > > Two words were not defined after I did this:
> > > - view* (it's easy, system/view)
> I don't think so, 'view* is defined in ctx-text.
Yeah, but:
>> ctx-text/view* == system/view
== true
On the circular reference issue:
To prevent circular references, I maintain
a list of the paths that have already been checked.
We will see if we can find each new path in the list.
If found, then we don't do it again.
If not found, we add it to the list and go into it.
See modified code at bottom.
A bit of testing from you guys out there and next
we should make a gui frontend for it. FX5 should maybe
incorporate it into RebSearch to extend the reach of
this cool rebol searching tool.
>> where? editor
...found in global context
==
>> where? pane
...found in 'face
...found in 'blank-face
...found in 'ctx-text/view*/screen-face
...found in 'ctx-text/view*/VID/vid-face
...found in 'ctx-text/view*/VID/choice-face
...found in 'ctx-viewtop/dtw-top
...found in 'ctx-viewtop/dtw-top/parent-face
...found in 'ctx-viewtop/dtw-b1
...found in 'ctx-viewtop/dtw-sid
...found in 'ctx-viewtop/dtw-mid
...found in 'ctx-viewtop/dtw-b2
...found in 'ctx-viewtop/dtw-bot
...found in 'ctx-viewtop/dtm-logo
...found in 'ctx-viewtop/dtm-services
...found in 'ctx-viewtop/dtm-face
...found in 'ctx-viewtop/dts-proto
...found in 'ctx-viewtop/dts-face
...found in 'ctx-viewtop/dti-stat
...found in 'ctx-viewtop/dti-info
...found in 'ctx-viewtop/dti-face
...found in 'ctx-viewtop/dtp-progress
...found in 'ctx-viewtop/dtp-progress/pane
...found in 'ctx-viewtop/dtp-progress/bar
...found in 'ctx-viewtop/dtp-status
...found in 'ctx-viewtop/dtp-what
...found in 'ctx-viewtop/dtp-face
...found in 'ctx-viewtop/dte-name
...found in 'ctx-viewtop/dte-status
...found in 'ctx-viewtop/dte-comps
...found in 'ctx-viewtop/dte-msg
...found in 'ctx-viewtop/dte-license
...found in 'ctx-viewtop/dte-face
...found in 'ctx-viewtop/dtf-icons
...found in 'ctx-viewtop/dtf-icons/pane
...found in 'ctx-viewtop/dtf-back
...found in 'ctx-viewtop/dtf-path
...found in 'ctx-viewtop/dtf-path/pane
...found in 'ctx-viewtop/dtf-slide
...found in 'ctx-viewtop/dtf-slide/pane
...found in 'ctx-viewtop/dtf-slide/dragger
...found in 'ctx-viewtop/dtf-face
...found in 'ctx-viewtop/dtg-path
...found in 'ctx-viewtop/dtc-icon
...found in 'ctx-viewtop/dtc-icon/pane
...found in 'ctx-viewtop/ii-name
...found in 'ctx-viewtop/ii-type
...found in 'ctx-viewtop/ii-info
...found in 'ctx-viewtop/ii-size
...found in 'ctx-viewtop/ii-date
...found in 'ctx-viewtop/ii-path
...found in 'ctx-viewtop/ii-lay
...found in 'ctx-edit/t1
...found in 'ctx-edit/s1
...found in 'ctx-edit/s1/pane
...found in 'ctx-edit/f1
...found in 'ctx-edit/ed-lo
...found in 'ctx-edit/save-lo
...found in 'ctx-edit/ff
...found in 'ctx-edit/fb
...found in 'ctx-edit/fc
...found in 'ctx-edit/find-lo
...found in 'hist-area
...found in 'hist-lay
==
REBOL [
Title: "Where tool"
Author: "Nenad Rakocevic"
Date: 24/04/2001
File: %where.r
Version: 0.1
Purpose: "Find in which objects words are defined"
; modified by Anton.
]
context [
ctx: fword: cto: val: pos: none
list: none
iter: has [w][
w: to-path :ctx ; the object
either find list w [
;print ["not checking:" :ctx]
][
;print ["now in list:" :ctx]
insert tail list w ; put this object in the list
if find first w :fword [
pos: either pos: find/match :ctx 'system/words [:pos][:ctx]
if empty? :pos [pos: either value? fword ["global context"][none]]
if pos [print ["...found in" :pos]]
]
foreach w next first w [ ; check each item of the object
cto: to-path :ctx
set/any 'val get/any in cto :w
if all [
value? 'val
not any-function? :val
object? val
:ctx <> 'system/words
:w <> 'system
:w <> 'REBOL
][
insert tail :ctx :w
iter ; recurse
]
]
]
remove back tail ctx
]
set 'where? func ['word][
ctx: to-lit-path 'system
fword: :word
list: make block! 400
iter
]
]
Regards,
Anton.