mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-12 06:19:33 -06:00
Syntax editor: select subset of available languages
Also added a basic readme file with a list of todo's
This commit is contained in:
32
src/www/syntax-editor/README.md
Normal file
32
src/www/syntax-editor/README.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# GF web-based syntax editor
|
||||
|
||||
John J. Camilleri
|
||||
November 2012
|
||||
|
||||
An improved version of the [old syntax editor][1].
|
||||
|
||||
[1]:http://www.grammaticalframework.org/~meza/restWiki/editor.html
|
||||
|
||||
## Notes
|
||||
|
||||
Tested with latest Chrome and Firefox.
|
||||
|
||||
## TODO
|
||||
|
||||
- Enter string/float/int literals
|
||||
- UI issue with DisambPhrasebookEng
|
||||
- more prominence to Disamb-linearizations
|
||||
- ambiguity: (optionally) parse all the resulting linearizations/variants and point out those which are ambiguous
|
||||
- random-generate a non-empty tree as a starting point
|
||||
- try to retain subtree when replacing node
|
||||
- add undo/redo (or back/forward) navigation
|
||||
- structure the set of fridge magnets some more. Even though they
|
||||
are alphabetically sorted, it's difficult to find the one that I want,
|
||||
maybe put a newline before the magnet whose first letter is different
|
||||
with respect to the previous magnet
|
||||
- The formal-looking funs and cats are not linked/aligned to the linearizations.
|
||||
Maybe a possible UI could be where the user is
|
||||
clicking on the linearization (in a chosen language) and the tree is
|
||||
drawn under it (from top to bottom, not from left to right as
|
||||
currently). So that the alignment of words to functions is always
|
||||
explicit. But maybe this is not doable.
|
||||
@@ -108,14 +108,16 @@ Editor.prototype.get_refinements=function(cat) {
|
||||
|
||||
Editor.prototype.select_refinement=function(fun) {
|
||||
with (this) {
|
||||
clear(ui.refinements);
|
||||
ast.removeChildren();
|
||||
ast.setFun(fun);
|
||||
// redraw_tree();
|
||||
|
||||
var args = {
|
||||
id: fun,
|
||||
format: "json"
|
||||
};
|
||||
var err = function(data){
|
||||
clear(refinements);
|
||||
alert("no refinements");
|
||||
};
|
||||
server.browse(args, bind(complete_refinement,this), err);
|
||||
@@ -139,7 +141,7 @@ Editor.prototype.complete_refinement=function(data) {
|
||||
}
|
||||
}
|
||||
|
||||
// Update vis
|
||||
// Update ui
|
||||
redraw_tree();
|
||||
update_linearisation();
|
||||
|
||||
|
||||
@@ -15,11 +15,22 @@ function EditorMenu(editor,opts) {
|
||||
this.container = editor.ui.menubar;
|
||||
this.ui = {
|
||||
startcat_menu: empty("select"),
|
||||
to_menu: empty_id("select","to_menu")
|
||||
to_toggle: button("...", function(){
|
||||
var sel = t.ui.to_menu;
|
||||
if (sel.classList.contains("hidden"))
|
||||
sel.classList.remove("hidden")
|
||||
else
|
||||
sel.classList.add("hidden")
|
||||
}),
|
||||
to_menu: node("select",{
|
||||
id: "to_menu",
|
||||
multiple: "multiple",
|
||||
class: "hidden"
|
||||
} )
|
||||
};
|
||||
with(this.ui) {
|
||||
appendChildren(this.container, [text(" Startcat: "),startcat_menu]);
|
||||
appendChildren(this.container, [text(" To: "), to_menu]);
|
||||
appendChildren(this.container, [text(" To: "), to_toggle, to_menu]);
|
||||
startcat_menu.onchange=bind(this.change_startcat,this);
|
||||
to_menu.onchange=bind(this.change_language,this);
|
||||
}
|
||||
@@ -119,10 +130,12 @@ EditorMenu.prototype.change_startcat=function () {
|
||||
|
||||
//
|
||||
EditorMenu.prototype.change_language=function () {
|
||||
if (this.ui.to_menu.value == "All")
|
||||
this.editor.languages = new Array();
|
||||
else
|
||||
this.editor.languages = new Array(this.ui.to_menu.value);
|
||||
this.editor.languages = new Array();
|
||||
for (i in this.ui.to_menu.options) {
|
||||
var opt = this.ui.to_menu.options[i];
|
||||
if (opt.selected)
|
||||
this.editor.languages.push(opt.value);
|
||||
}
|
||||
this.editor.update_linearisation();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,18 @@ body {
|
||||
background: #ccc url("http://cloud.grammaticalframework.org/minibar/brushed-metal.png");
|
||||
}
|
||||
|
||||
.hidden
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
|
||||
select#to_menu
|
||||
{
|
||||
height: 10em;
|
||||
position: absolute;
|
||||
min-width: 5em;
|
||||
}
|
||||
|
||||
#tree
|
||||
{
|
||||
white-space:pre;
|
||||
|
||||
Reference in New Issue
Block a user