[plt-scheme] Grafting a console onto universe, hackety hack.

From: Jordan Johnson (jmj at fellowhuman.com)
Date: Thu Jun 3 03:08:06 EDT 2010


On Jun 2, 2010, at 7:24 PM, Matthias Felleisen <matthias at ccs.neu.edu>  
wrote:
> I am trying to figure what exactly you're trying to achieve.
> I have parameterized the 'world' over many things with mixins
> and all, but I have not considered a reuse where you want to
> bring events from somewhere else. I think it should be possible
> to expose some private interface -- if I knew what you wanted.

Sorry if the example code wasn't clear.   I'm thinking of the  
Interactions window, or further afield, some chat and MUD clients, or  
terminal emulators, where the user interface essentially consists of:
  - a command line for entering text
  - a scrolling display of the interaction history, which cannot be  
edited

Implementing all of this using big-bang is certainly doable, but  
around the point of implementing the scrolling display it starts  
seeming cumbersome and silly to reimplement all the niceties of such  
an interface.  So my main interest is in seeing how to make use of the  
widget classes that are already written.

As for the specific question about why I'm talking about triggering  
events from the class:  I found pretty quickly that if I didn't create  
a separate eventspace for the new frame, the event handling didn't  
work right. (I don't remember all the details right now, but I think  
the program wasn't recognizing keystrokes unless the window created by  
on-draw had focus, or something similar.)  aftwr that discovery, the  
specific scenario I was asking about in the original post inolved this  
desired behavior:
  1) the user of the world program types a message and presses Enter
  2) the program sends a representation of that message to the universe
  3) the user's input (and any response from the universe) is  
displayed in the console

With the code I've written, the problem I see is in step (2): if the  
text-field% has to be in a separate eventspace and so isn't being  
manipulated by key-events in the universe teachpack, then what will  
trigger the sending of the message to the server?  The only way to do  
that is by returning a package from one of the handlers registered  
with big-bang...and those only get called in response to events the  
universe teachpack knows about.

Does that make my intent clearer?

Best,
Jordan

>
>
>
>>   2) whether there's any locking I'd need to do to make it safe for  
>> both the
>>     user-input-callback (see below) and a universe/big-bang event  
>> handler
>>     callback to call append-line as I'm doing below
>
>
> When you write GUI programs, you are writing concurrent programs.
> There are at least two processes involved: your program and the person
>  sitting at the console.
>
>
>>   3) whether overriding on-char is really an OK way to make a text%  
>> object
>>     "read-only" from the user's perspective
>
> (send text lock #t)
>
>>   4) whether there's already some spiffy console-style class I've  
>> missed in
>>     the docs :)
>
> Again, what are you trying to do?
>
> One could imagine factoring it out the drracket console.
>


Posted on the users mailing list.