[plt-scheme] WXME Decoding Error
Matthew,
Thanks for the suggestion on my WMXE file-reading problem. In the end,
I seem to have squashed (most of) that bug by more careful study of
additional parts of the Framework docs. I hadn't read the Handler
chapter, so I was getting a default editor. Now I've got appropriate
calls to handler:insert-format-handler and
handler:current-create-new-window so I get the right kind of window,
which gives me my pasteboard% subclass as expected (and thus eliminates
the unexpected text% editor).
I've still got a few residual questions:
1- I also found the Finder chapter, and have calls to set up
finder:default-extension and finder:default-filters. However, these
seem to only affect the Save/Save-As dialogs. The Open dialog still
comes up with "Any" as its only filter. Is there a comparably simple
way to set default filters on that dialog as well?
2- After my now (mostly) successful file load, I'm still getting the
following error message:
> send: no such method: set-position for class: eer-pasteboard%
Based on searching the docs, this method seems to be associated with
scroll-event%s and text% editors. So maybe there's somewhere else in
the framework that is still expecting a text% object? Any thoughts on
what else I might have overlooked as a PLT GUI newbie?
3- Let me take another shot at the other query I threw into my initial
email: Where should I be stashing, and how should I be accessing, global
(for a given editor's diagram or graph structure) state-objects, such
that the specialized "read" methods of my specialized snip-class%s can
find that state-object (say, in order to log the newly created snip%s
into that object, or look up previously created snip%s or other
underlying application objects that a new snip is supposed to connect up
with)?
My current (bogus-feeling) approach is to count on the read method being
called after on-file-load has run (and before any other on-file-load has
run) so I can set up a global variable with a state-object for the
file's contents. As I said, this feels bogus, but I don't see how to
make such shared data accessible to the read methods of these
snip-class%s... I started down the header/footer path at one point, but
there's really no more data that needs to be stored in the file
format--what I need to know is all part of (of reconstructible from) the
snip data.
I suppose after the read methods complete there is an implicit call to
the editor%'s insert method. Is that the place to put any such
editor-state-dependent code? That seems a little funky, as I think of
the state-management as being part of the creation of a
complete/consistent snip% object (which seems like the job of read).
I'd also have to overhaul the editor-actions that create the snip%s so
that they rely on the same magic insert behavior to complete the snip%
data structures. Then of course there's figuring out if what I really
want is to tack this onto on-insert or after-insert, and what to do
about edit-sequences... Somehow I was hoping for a simpler solution.
4- One final info-access style question: What is the right way to figure
out the directory from which a module is being loaded? My problem here
is that I want my custom editor app to use some custom icons, so I've
got an icons sub-directory beneath the directory that holds my code, but
I don't know how to establish dynamically the directory that the code is
loading from. This seems like there must be a simple straightforward call.
Oh yes... I doubt it matters for these queries, but I forgot to say in
my original note: I'm working with PLT 4.1.1 on Windows XP.
Thanks as always for the great support here.
--Eric
Matthew Flatt wrote:
> At Fri, 10 Oct 2008 17:42:36 -0400, Eric Domeshek wrote:
>
>> But today I seem to have run into a bit of a brick wall in attempting to
>> use the WXME encoding/decoding piece of the framework to save and reload
>> my diagrams. I've gotten a far as saving the data (writing a file with
>> seven types of custom snips). Unfortunately, I can't load the data back
>> in, and the error message/trace is not helping me much. Here's what
>> comes up in the console window when I try to load one of these saved
>> files by invoking the default File|Open command:
>>
>>
>>> insert-file in text%: error loading the file
>>>
>>> [...]
>>>
>>>
>> Can anyone suggest a way forward? For starters, I'm not sure why
>> there's a text% floating around. I've only been dealing with
>> pasteboard%s.
>>
>
> I don't have any great ideas, but you might try parsing the file using
> the `wxme' library, which might give better information about decoding
> problems.
>
> I'm puzzled by the "insert-file in text%" message, too. Looking at the
> source where that message can be reported, it seems to be always within
> a `text%' object, and never in a `pasteboard%'.
>
> If you're able and willing to send me code so I can see the problem on
> my machine, I would try it out.
>
>
>
>> Also, while I'm asking questions... As I read in my data, I need to
>> create some custom structures that get wrapped inside my snips (i.e.
>> "nodes" and "links" in an underlying graph structure). That custom data
>> all needs to be attached to a diagram-level object (the "graph"). But I
>> don't see how the read methods in my various snip-class%es can best get
>> hold of the diagram object (which is stashed in the frame%, which holds
>> the pasteboard%, which will contain the snip%s that get created by those
>> snip-class% read methods). For now, I've got a pasteboard% on-load-file
>> method setting a global variable so my various read methods can get hold
>> of that shared diagram. This seem ugly. Any better ideas?
>>
>
> I'm not sure I understand, but I wonder whether the information should
> instead reside in the pasteboard so that it's written and restored
> though `write-editor-global-footer' and `read-editor-global-footer'?
>
>
> Matthew
>