Home › Forums › General XMetaL Discussion › May I get automatic enter key when typing to XMetal Author? › Reply To: May I get automatic enter key when typing to XMetal Author?
Reply to: May I get automatic enter key when typing to XMetal Author?September 9, 2010 at 7:19 pm
Do you mean you have an element where carriage returns are relevant, and need to be inserted every 80 characters?
If so, this could be handled various ways. Here are some thoughts…
1) Allow the author to type freely within the element and not worry about carriage returns at all. Then modify the document before saving (good events for this are On_Before_Document_Validate or On_Before_Document_Save) by walking through it, finding each relevant element and making changes to its PCDATA content using script.
2) Implement an XFT form containing a “MultiEditBox” control together with script inside the form that inserts carriage returns at the relevant locations (and possibly strips others out). You might render the form inline (embedded) and style it so that the author feels they are editing this element as if it was a regular element and typing directly into the document. This would only work for Tags On and Normal view. In addition, you should avoid this option if your documents will contain many of these elements as using too many embedded XFT forms in a document can slow editing down (each one gets its own separate Windows Script Engine and associated memory and CPU overhead, this is analogous to running several copies of Internet Explorer at one time).
3) Handle this outside of XMetaL (after saving) using XSLT or other type of transformation. The author would then (similar to #1) not worry about the content of these elements at all and the carriage returns would be inserted automatically (and they might never even know about it). It can often be a good idea to separate this type of thing from the authoring process completely when the user should have no control over it as they will then not waste time concerning themselves asking “did this particular line get wrapped properly during editing”.
4) You might be able to do this with Pretty Printing. You would need to turn pretty printing on in the CTM file, set the global MaxLineLength property to 80 characters (which is in fact the default value), then probably disable indenting for the elements in question. Finally, you'd probably need to set
Note that if you wish the author to be able to see these significant carriage returns (and you are not embedding an XFT form into the document) you will need to set the CSS property “white-space:pre” for the relevant element(s). Keep in mind that this does not affect the font being used, just whether or not white-spaces are displayed to the author (so if you wish to use a monospaced font to mimic the HTML “pre” for example, you would need to specifically set that with a font-family CSS property.