[plt-scheme] editor lockup in embedded editor-snip%
That code by itself isn't enough for me to see what's wrong and you
could certainly be running across a bug elsewhere in the system. The
most useful thing would be a (small!) program that illustrated the
problem, but if you can't seem to narrow down, send along what you've
got and I'll have a look.
Robby
On Thu, Aug 20, 2009 at 1:37 PM, Jordan Johnson<jmj at fellowhuman.com> wrote:
> Hi all,
>
> The annotated-code snip I've been working on is now working (thanks in large
> part to help from Matthew & Robby), with the exception of one bug that has
> me baffled. I suspect it involves the locking that happens in
> embedded-gui/aligned-pasteboard.
>
> The bug: If I have a snip in the Definitions editor and click "Run" while
> the snip's code-view (defined below) is hidden, it becomes impossible to
> edit the text in the code-editor (also defined below). By this I mean that
> when I click or tab into the code editor, the cursor does not appear, and
> typing has no effect. Further, this only happens when the editor is not
> visible.
>
> Here is the relevant code:
>
> ;;;;;;;;;
> ;; anno-snip% is my snip's class.
>
> ;; code-editor is an instance of a subclass of
> ;; ((drscheme:unit:get-program-editor-mixin) (tabbable-text-mixin
> scheme:text%))
> ;; that caches the result of (scheme:text-balanced? this) for display
> purposes.
>
> ;; anno-editor is an instance of (tabbable-text-mixin scheme:text%).
>
> ;; The following is from the definition of a subclass of
> ;; aligned-pasteboard% that is the editor for an anno-snip%:
>
> (set-tabbing code-editor anno-editor)
>
> ;;;;;;; Container snips for the two editors:
> (define val (new vertical-alignment% [parent this]))
> ;; Container for the code editor. I'm using this for the ability to
> ;; show/hide the editor:
> (define code-view (new vertical-alignment%
> [parent val]
> [show? #f]))
>
> ;; Installs stretchable editor snips, if none are already installed,
> ;; to contain the code and anno editors.
> ;; (Does nothing if they already are installed, and returns #f.)
> ;; Returns #t if successful.
> (define (init-snips)
> (if (not (or (find-owner-snip code-editor)
> (find-owner-snip anno-editor)))
> (let ([code-snip (new stretchable-editor-snip%
> [editor code-editor]
> [with-border? #t]
> [min-width MIN-TEXT-WIDTH])]
> [anno-snip (new stretchable-editor-snip%
> [editor anno-editor]
> [with-border? #f]
> [min-width MIN-TEXT-WIDTH])])
> (make-object snip-wrapper% code-view code-snip)
> (make-object hline% code-view)
> (make-object snip-wrapper% val anno-snip)
> #t)
> #f))
>
> (init-snips)
>
> ;;;;;;;;; Interface for showing/hiding code ;;;;;;;;;
> (define showing-code #f)
>
> (define/public (showing-code?)
> showing-code)
> (define/public (show-code on/off)
> (send code-view show on/off)
> (set! showing-code on/off))
>
> ;;;;;;;;; end of program excerpt.
>
> I have verified that the code-editor is *not* locked for writing, reflowing,
> or reading. Having looked at snip-wrapper.ss and aligned-pasteboard.ss in
> embedded-gui/private/, I am guessing something in the code-editor's or
> code-snip's state isn't getting properly restored when it is reinserted by
> show/hide (in snip-wrapper.ss), but I don't know what that piece of state
> would be. Any pointers?
>
> Oh, and here's an extra question that may be related: How can I give the
> caret to the code editor upon calling (show-code true)? Calling
> set-caret-owner on the code-snip's snip-admin doesn't seem to work.
>
> Thanks again for your help.
>
> Best,
> jmj
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>