Hi Anton

OK, as a public service, I will reveal one of my secret Jedi methods. :-)

This one is called "Use the Source!"

All of the desktop code is in ctx-viewtop which is initially a spec block
for an object (or context). When the desktop is invoked ctx-viewtop is
converted (if necessary) to an object. It is about 1000 lines of code.

You can make yourself a cheat-sheet as follows, will work with either block
or object

echo %viewtop.txt
print mold ctx-viewtop
echo none

With regard to services, look for the function show-services. You can show
it as follows if ctx-viewtop is an object. The conversion (if necessary)
should be done this way.

if block? ctx-viewtop [ctx-viewtop: context ctx-viewtop]

>> print mold get in ctx-viewtop 'show-services

func [file /local path services f x][
    clear next dts-face/pane
    x: dts-face/pane/1/size/x
    path: full-path file
    if all [services: load-index path services/icons] [
        foreach icon services/icons [
            if icon/type = 'service [
                f: make-face dts-proto
                f/text: icon/name
                f/size: 200x20
                f/line-list: none
                f/action: compose/deep [
                    do-file (either word? icon/item [to-lit-word icon/item]
[icon/item]
)
                    (if icon/stats [reduce [icon/stats]])
                ]
                f/size/x: 4 + first size-text f
                x: x + 8
                f/offset/x: x
                x: x + f/size/x
                append dts-face/pane f
            ]
        ]
    ]
    dtm-services/pane: dts-face/pane
    dtm-services/size: dts-face/size
    dtm-services/size/x: x
    show dtm-services
]

The line starting f/action: tells us the action that happens when we click
the item in the services bar.  In this case, it will call the function
do-file on the argument.

>> print mold get in ctx-viewtop 'do-file

func [path stats /local orig][
    if none? path [exit]
    orig: path
    if word? path [
        switch path [
            goto [goto-view]
            help [help-view]
            console [halt-view]
            quit [quit]
        ]
        exit
    ]
    if email? path [emailer/to path exit]
    if not any [url? path (first path) = #"/"] [path: full-path path]
    either not read-binary path stats [
        alert reform ["Missing file:" path]
    ] [
        switch/default map-suffix to-file path [
            rebol [start path]
            text [editor path-thru path]
            image [show-image path]
        ] [
            either url? orig [browse orig] [browse path-thru path]
        ]
    ]
]

Reading the above code and a couple of quick experiments gave me the
information for my email below.

Happy Hacking
-Larry

PS The functions INIT-DESKTOP and CONNECT-VIEW are worth study.

----- Original Message -----
From: "Anton" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 03, 2001 10:55 AM
Subject: [REBOL] Re(2): services.r


> Larry,
>
> How did you find this out?
> Where's the source that understands the "service" dialect?
> In which context are the words that you can use
> with service; goto, help and quit?
>
> Anton.
>
> > > Just add a menu item that brings up the editor to edit one
> > > of my remote files
>
> > A service has to be either a word or a url/file. Make a script
> > called edit.r
> > with these lines
> >
> > REBOL []
> > editor http://www.rebol.com        ;change file/url as necessary
> >
> > and put in the view-root directory.
> >
> > Add this line to services.r
> >
> > service "Edit" %edit.r
> >
> > This will invoke the editor on the file or url specified. The line
> >
> > editor 'same
> >
> > invokes the editor with a blank document.
> >
> > -Larry
>
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to