[plt-scheme] editor snips and replacing the editor with set-editor

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Sat May 24 23:23:58 EDT 2008

Hi everyone,


I'm trying to create an editor snip that doesn't allow further edits to 
it.  I tried the following, but the resulting snips that show up on the 
interaction window continue to allow internal editing.  I'm missing 
something obvious but I don't quite see the problem yet.


Any suggestions?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang scheme/base
(require scheme/gui/base
          scheme/list
          scheme/class
          scheme/sandbox)


(define immutable-text%
   (class text%
     (inherit insert)

     (init content)
     (define after-initialize? #f)

     (define (initialize)
       (super-new)
       (insert content)
       (set! after-initialize? #t))

     (define/augment (can-insert? pos len)
       (not after-initialize?))

     (define/augment (can-delete? pos len)
       (not after-initialize?))

     (initialize)))


(define immutable-editor-snip%
   (class editor-snip%
     (inherit set-editor)
     (init content)
     (define (initialize)
       (super-new)
       (set-editor (new immutable-text% [content content])))

     (initialize)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Posted on the users mailing list.