theodore-norvell / PLAAY

Senior Design Project PLAAY (Programming Language for Adults And Youth)
2 stars 0 forks source link

Templates for types #27

Closed theodore-norvell closed 6 years ago

theodore-norvell commented 7 years ago

Currently there doesn't seem to be a way to add types to variable declarations.

theodore-norvell commented 7 years ago

We need palette items for these templates.

theodore-norvell commented 6 years ago

See the Types in PLAAY documentation for the kinds of types.

We need the following new label classes.

In terms of how these should look (i.e. convert to html or svg)

All borders and symbols should be the same colour. Let's try yellow to start. rgb(211,50,9)

theodore-norvell commented 6 years ago

In terms of editing, we need a new palette for types. So there will be an expression palette and type palette. These palettes can just be side-by-side.

Some of the editing actions can be shared by the two pallettes, for example, the "makeTupleNode" action of the treeManager can be invoked from either palette or from pressing the "(" key. The makeTupleNode function in treeManager currently does a replaceEngluf with one template. We can modify it by adding a second template that makes uses a TupleTypeLabel instead of a TupleLabel. If the first template fails, the second template will be tried. Since expressions are not allowed where types are allowed and conversely, this will work. For example if the current selection is a place where a type can go but an expression can not, hitting the "(" key will make a TupleTypeLabel( ExpPH, ExpPH ). But if the current selection is a place where an expression can go, hitting the "(" key will make a TupleType( ExpPH, ExpPH ) as it does currently.

We can have shared keyboard shortcuts as follows

also the following keyboard shortcut is not shared

The following pairs of palette items can share their behaviour (i.e. they invoke the same action in the treeManager, which then uses a choice of templates or a choice of edits (two edits can be combined with the alt function from the edits module to make an edit that does one or the other of them).

theodore-norvell commented 6 years ago

Made new actions for keyboard so that the buttons are single purpose (either type or expression) by the keyboard shortcuts are alternatives.