From dfbf4f9e145a482aa85d42e7373422fd57d619b3 Mon Sep 17 00:00:00 2001 From: hallgren Date: Mon, 3 Oct 2011 08:21:35 +0000 Subject: [PATCH] gfse: references to the GF book in keyword tool tips and style tweaks for example-based grammar editing --- src/editor/simple/editor.css | 12 ++++++++---- src/editor/simple/editor.js | 29 +++++++++++++++++++---------- src/editor/simple/example_based.js | 4 ++-- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/editor/simple/editor.css b/src/editor/simple/editor.css index d7a415186..489a1d81b 100644 --- a/src/editor/simple/editor.css +++ b/src/editor/simple/editor.css @@ -28,10 +28,14 @@ td.right { text-align: right; } div.indent { padding-left: 1em; min-width: 1em; min-height: 1em; } -/* -div.fun, div.param, div.lincat, div.oper, div.lin -{ padding-left: 2em; text-indent: -2em; } -*/ +div.fun:hover, div.param:hover, div.lincat:hover, div.oper:hover, div.lin:hover, +div.template:hover +{ background: #def;} + +.lin input[type=button], +.template input[type=button] { float: right; clear: right; } +.exb_output { background: #dfd; float: right; margin: 0 10px; } + .more, .delete { font-weight: bold; font-family: sans-serif; } .more, .delete, .edit { cursor: pointer; } diff --git a/src/editor/simple/editor.js b/src/editor/simple/editor.js index a2ddc80b3..8560f561f 100644 --- a/src/editor/simple/editor.js +++ b/src/editor/simple/editor.js @@ -293,9 +293,9 @@ function draw_startcat(g) { function draw_abstract(g) { var kw_cat = kw("cat"); - kw_cat.title = "The categories (nonterminals) of the grammar are enumerated here."; + kw_cat.title = "The categories (nonterminals) of the grammar are enumerated here. [C.3.2]"; var kw_fun = kw("fun"); - kw_fun.title = "The functions (productions) of the grammar are enumerated here."; + kw_fun.title = "The functions (productions) of the grammar are enumerated here. [C.3.4]"; var flags=g.abstract.startcat || g.abstract.cats.length>1 ? draw_startcat(g) : text(""); @@ -481,6 +481,14 @@ function draw_concrete(g,i) { } string_editor(el,conc.langcode,change_langcode) } + var kw_lincat=kw("lincat") + kw_lincat.title="The linearization type for each catagory in the abstract syntax is given here. [C.3.8]" + var kw_lin=kw("lin") + kw_lin.title="The linearization function for each function in the abstract syntax is given here. [C.3.9]" + var kw_param=kw("param") + kw_param.title="Parameter type definitions can be added here. [C.3.12]" + var kw_oper=kw("oper") + kw_oper.title="Operation definitions can be added here. [C.3.14]" return div_id("file", [kw("concrete "), ident(g.basename), @@ -489,10 +497,10 @@ function draw_concrete(g,i) { kw(" of "),ident(g.basename),sep(" = "), draw_timestamp(conc), indent([extensible([kw("open "),draw_opens(g,i)])]), - indent([kw("lincat"),draw_lincats(g,i)]), - indent([kw("lin"),draw_lins(g,i)]), - indent([extensible([kw("param"),draw_params(g,i)])]), - indent([extensible([kw("oper"),draw_opers(g,i)])]), + indent([kw_lincat,draw_lincats(g,i)]), + indent([kw_lin,draw_lins(g,i)]), + indent([extensible([kw_param,draw_params(g,i)])]), + indent([extensible([kw_oper,draw_opers(g,i)])]), exb_extra(g,i) ]) } @@ -655,7 +663,7 @@ function draw_lincats(g,i) { var cat=c.cat; var err=!dc[cat]; var l1=dlc(c,"lincat"); - var l2= err ? deletable(del(cat),l1,"Delete this lincat") : l1; + var l2= deletable(del(cat),l1,"Delete this lincat"); var l=ifError(err,"lincat for undefined category",l2); delete dc[cat]; return node_sortable("lincat",cat,[l]); @@ -817,7 +825,7 @@ function draw_lins(g,ci) { function draw_lin(f) { var fun=f.fun; var err= !df[fun]; - var l= err ? deletable(del(fun),dl(f,"lin"),"Delete this function") : dl(f,"lin") + var l= deletable(del(fun),dl(f,"lin"),"Delete this linearization function") var l=ifError(err,"Function "+fun+" is not part of the abstract syntax",l); delete df[fun]; return node_sortable("lin",fun,[l]); @@ -828,8 +836,8 @@ function draw_lins(g,ci) { return arg_names(funs[i].type); } function dtmpl(f) { - return wrap("div", - dl({fun:f,args:largs(f),lin:"",template:true},"template")); + return div_class("template", + [dl({fun:f,args:largs(f),lin:"",template:true},"template")]); } function sort_lins() { conc.lins=sort_list(this,conc.lins,"fun"); @@ -1010,6 +1018,7 @@ function text_ne(s) { // like text(s), but force it to be non-empty function editable(tag,cs,g,f,hint) { var b=edit_button(function(){f(g,e)},hint); var e=node(tag,{"class":"editable"},[cs,b]); + //e.onclick=b.onclick; return e; } diff --git a/src/editor/simple/example_based.js b/src/editor/simple/example_based.js index f38f657c7..07725d242 100644 --- a/src/editor/simple/example_based.js +++ b/src/editor/simple/example_based.js @@ -146,11 +146,11 @@ function exb_linbuttons(g,ci,f) { if(conc.example_based && eb) { if(eb.exready[fun]) buttons.push(button("By example",by_example)) - if(eb.testable[fun]) { + if(eb.testable[fun] && f.eb_lin) { var b=button("Test it",test_it); buttons.push(b) } - var exb_output=empty("span"); + var exb_output=node("span",{class:"exb_output"},[]); buttons.push(exb_output) } return buttons