From 818faee27e8c6fde5fc6b2cac9151667f67b1503 Mon Sep 17 00:00:00 2001 From: hallgren Date: Mon, 26 Nov 2012 14:11:12 +0000 Subject: [PATCH] gfse: more readable layout for not so simple grammars + bug fix To make definitions that span multiple lines more readable in guided mode, preserve line breaks and indentation when lin and oper definitions are displayed and edited in guided mode. Bug fix: moving the cursor by clicking and selecting text by dragging did not work in textareas and input fields, because those mouse event were intercepted by the sort-by-drag-and-drop handler. --- src/www/gfse/editor.css | 6 +++++- src/www/gfse/editor.js | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/www/gfse/editor.css b/src/www/gfse/editor.css index 6f11004cb..fa5d21306 100644 --- a/src/www/gfse/editor.css +++ b/src/www/gfse/editor.css @@ -77,6 +77,9 @@ div.template:hover tr.deletable:hover .delete { visibility: visible; } +.editable { white-space: pre; } +div.lin span.editable { display: inline-block; vertical-align: top; } + .more { color: green; } .edit { color: orange; } .delete { color: red; } @@ -110,7 +113,8 @@ table.tabs input[type=button], table.matrixview th input[type=button] { /*text-decoration: underline;*/ } -input.string_edit { font-family: inherit; font-size: inherit; } +.string_edit { font-family: inherit; font-size: inherit; } +textarea.string_edit { vertical-align: top; } ul.languages { -moz-column-width: 20em; } diff --git a/src/www/gfse/editor.js b/src/www/gfse/editor.js index ed8988f79..059c0715a 100644 --- a/src/www/gfse/editor.js +++ b/src/www/gfse/editor.js @@ -1798,9 +1798,16 @@ function string_editor(el,init,ok,async) { e.it.focus(); } var m=empty_class("span","error_message"); - var i=node("input",{"class":"string_edit",name:"it",value:init},[]); - if(init.length>10) i.size=init.length+5; -// var i=node("textarea",{name:"it",rows:"2",cols:"60"},[text(init)]); + if(init.indexOf("\n")>=0) { + var rows=init.split("\n").length+1 + var i=node("textarea",{"class":"string_edit",name:"it", + rows:rows,cols:"80"}, + [text(init)]); + } + else { + var i=node("input",{"class":"string_edit",name:"it",value:init},[]); + if(init.length>10) i.size=init.length+5; + } var e=node("form",{}, [i, text(" "), @@ -1996,7 +2003,8 @@ if(editor) { initial_view(); touch_edit(); dir_bugfix(); - initialize_sorting(["DIV"],["fun","lin","lincat","oper"]); + initialize_sorting(["DIV","INPUT","TEXTAREA"], + ["fun","lin","lincat","oper"]); } else editor.innerHTML="

This browser does not appear to support localStorage, and the grammar editor does not work without it. Sorry!"