I'm looking to make a structure editor for racket code, with an eye to perhaps eventually integrating it into the DrRacket IDE.
I haven't used Racket/Draw or Racket/GUI before and I'm currently evaluating their suitability for the task. In general, I'm eager for relatively simple Racket/GUI examples; I've been reading the docs directly, but there are lots of things I'm confused about. I don't have very much GUI experience in general, though I've done a couple small things using Swing in Java. I have some specific questions below but generally I'm looking for guidance in using racket/gui or any other libraries that might be of help here. For the sake of starting somewhere, I'm just trying to make an editor for tree-structured data, without interpreting it as source code as such. That is, I want to make something that opens/saves text files containing (parenthesized) s-expressions whose atoms are (alphanumeric) symbols. I want to represent these s-expressions on-screen as a system of nested boxes. Eventually I want to do fancy things with layout, so I'd like to keep things as abstract as is realistic. Specifically, I don't want to rely too much on text-based flow built-in to whatever library I use, though I am willing to do so to start. So let's say that my atoms will originally be boxes containing text; text% snips from racket/gui seem suitable, and the surrounding box structures can be implemented using text% objects to start, then perhaps pasteboard% objects to allow for more complex flow/positioning. I've already written code that will take an s-expression, and create a nested structure of text% objects on a canvas as described above, but I'm not sure I'm doing it in a very principled way. Specifically, I'd like advice on the best way to approach this from the perspective of 'un-parsing' whatever structure I create to an s-expression when i want to 'save'. What I want to do next is implement both keyboard and mouse controls to navigate through the tree. Specifically, assign keys to select parent/next-child, etc. I'm getting a vague idea of how to do this from the docs but examples would help. Basically the event model is not clear to me, and I am having trouble disentangling snips, editors, administrators, etc. I'm also trying to figure out how to visually indicate a selected subtree. I figured this would be possible using the the style<%> interface, but AFAICT it only has in-built support for text styling; that is, I can't figure out how to change either the background or stroke color of an embedded text% or pasteboard% snip. Presumably I can do this by creating a custom snip% class, which I'm sure I'll want to do at some point, but I'm wondering if I've missed something simpler? I'm also looking for advice on modelling the abstract idea of a 'selection'. To support the functionality I eventually want to create, I want the ability to create 'complex selections' to support structured tree transformations. By this I mean the ability to select a subtree, and the make 'holes' in it by un-selecting certain branches of that subtree - as well as the ability to simultaneously select multiple distinct subtrees. To start with though I just want to implement a simple set of transformations which operate on a single selected subtree. For example, if the selection is a text atom, one transformation would be to overwrite that text. Similarly, I want to implement transformations to create a new child of a selected node, to insert a new parent node between a selected node and its parent, to create new sibling nodes to the left/right of a selected node, and to delete a selected subtree. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.