mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-21 17:12:50 -06:00
Syntax editor: AST string always shown, remove export button
This commit is contained in:
@@ -35,7 +35,7 @@ body.syntax-editor {
|
|||||||
padding: 0.2em;
|
padding: 0.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tree
|
#tree, #tree_str
|
||||||
{
|
{
|
||||||
white-space:pre;
|
white-space:pre;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
@@ -69,6 +69,12 @@ body.syntax-editor {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#tree_str
|
||||||
|
{
|
||||||
|
font-size:0.85em;
|
||||||
|
color:#666;
|
||||||
|
}
|
||||||
|
|
||||||
#refinements
|
#refinements
|
||||||
{
|
{
|
||||||
/* display: inline-block; */
|
/* display: inline-block; */
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ function Editor(gm,opts) {
|
|||||||
|
|
||||||
tree: div_id("tree"),
|
tree: div_id("tree"),
|
||||||
|
|
||||||
|
tree_str: div_id("tree_str"),
|
||||||
|
|
||||||
actionbar: div_id("actions"),
|
actionbar: div_id("actions"),
|
||||||
clear_button: button("Clear", function(){
|
clear_button: button("Clear", function(){
|
||||||
t.clear_node();
|
t.clear_node();
|
||||||
@@ -55,6 +57,7 @@ function Editor(gm,opts) {
|
|||||||
appendChildren(this.container, [
|
appendChildren(this.container, [
|
||||||
t.ui.menubar,
|
t.ui.menubar,
|
||||||
t.ui.tree,
|
t.ui.tree,
|
||||||
|
t.ui.tree_str,
|
||||||
t.ui.actionbar,
|
t.ui.actionbar,
|
||||||
t.ui.lin
|
t.ui.lin
|
||||||
]);
|
]);
|
||||||
@@ -519,6 +522,7 @@ Editor.prototype.redraw_tree=function() {
|
|||||||
}
|
}
|
||||||
with(this) {
|
with(this) {
|
||||||
clear(ui.tree);
|
clear(ui.tree);
|
||||||
|
ui.tree_str.innerText = ast.toString();
|
||||||
visit(ui.tree, new NodeID(), ast.root);
|
visit(ui.tree, new NodeID(), ast.root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -582,4 +586,3 @@ Editor.prototype.import_ast = function(abstr) {
|
|||||||
};
|
};
|
||||||
t.server.pgf_call("abstrjson", args, cont, err);
|
t.server.pgf_call("abstrjson", args, cont, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ function EditorMenu(editor,opts) {
|
|||||||
show_to_menu: true,
|
show_to_menu: true,
|
||||||
show_random_button: true,
|
show_random_button: true,
|
||||||
show_import: true,
|
show_import: true,
|
||||||
show_export: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply supplied options
|
// Apply supplied options
|
||||||
@@ -47,9 +46,7 @@ function EditorMenu(editor,opts) {
|
|||||||
toggleHidden(t.ui.import.panel);
|
toggleHidden(t.ui.import.panel);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
export_button: button("Export", function(){
|
|
||||||
alert(t.editor.ast.toString());
|
|
||||||
}),
|
|
||||||
debug_toggle: button("⚙", function(){
|
debug_toggle: button("⚙", function(){
|
||||||
toggleHidden(element("debug"));
|
toggleHidden(element("debug"));
|
||||||
})
|
})
|
||||||
@@ -57,7 +54,6 @@ function EditorMenu(editor,opts) {
|
|||||||
this.ui.to_toggle.title = "Select languages to linearise to (use Ctrl/Shift to select multiple)";
|
this.ui.to_toggle.title = "Select languages to linearise to (use Ctrl/Shift to select multiple)";
|
||||||
this.ui.random_button.title = "Insert a randomly generated tree at the current node";
|
this.ui.random_button.title = "Insert a randomly generated tree at the current node";
|
||||||
this.ui.import.toggle.title = "Import an abstract syntax tree from a string (replaces current tree)";
|
this.ui.import.toggle.title = "Import an abstract syntax tree from a string (replaces current tree)";
|
||||||
this.ui.export_button.title = "Get the string representation of the abstract syntax tree";
|
|
||||||
this.ui.debug_toggle.title = "Toggle the debug console";
|
this.ui.debug_toggle.title = "Toggle the debug console";
|
||||||
|
|
||||||
if (t.options.show_grammar_menu) {
|
if (t.options.show_grammar_menu) {
|
||||||
@@ -95,11 +91,7 @@ function EditorMenu(editor,opts) {
|
|||||||
t.ui.import.button
|
t.ui.import.button
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
if (t.options.show_export) {
|
|
||||||
appendChildren(t.container, [
|
|
||||||
t.ui.export_button,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
appendChildren(t.container, [t.ui.debug_toggle]);
|
appendChildren(t.container, [t.ui.debug_toggle]);
|
||||||
|
|
||||||
/* --- Client state initialisation -------------------------------------- */
|
/* --- Client state initialisation -------------------------------------- */
|
||||||
@@ -200,4 +192,3 @@ EditorMenu.prototype.update_language_menu=function(menu,grammar) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user