Release Notes > 12.1.1.0 > Updates in This Release > User Interface Changes > Yellow Bar Updates
  
Yellow Bar Updates
XML Pretty Print Or Normalise Space
When working with XML content, it is often provided as a single long line of content, which is difficult to navigate and read. Two new fStream methods have been provided (and macros) to help.
fStream.xmlPrettyPrint() — this method allows the stream to be ‘pretty printed’. That is, elements will be indented to a depth greater than that of their parent element and the same depth as their siblings. This makes the content much more readable and easier to see which elements belong to which. The fStream.xmlPrettyPrint() method can take up to two parameters:
The first parameter is a string of characters to use as the indent. If this is not provided, a default of two spaces is used.
The second specifies whether to set the whitespace handling flags (maps tabs to spaces, ignore leading and multiple spaces). This is important as pretty printing XML content can change the output if whitespace isn’t handled well
fStream.xmlNormalizeSpace() — this method normalises the whitespace in the stream. It will remove multiple, leading and trailing whitespace characters. The method can take an optional parameter to specify the strip space control stream to use when normalising the whitespace.
These options are provided on the Stream Properties toolbar via the following icons:
Autoindent
When working with either XML or JavaScript in the yellow bar, it is often tedious to have to add indents by hand every time a new line is started. Imagine adding 10 or 12 spaces every time you insert a new line in an XML file or JavaScript function! Version 12.1.0.0 provides a new method to automatically indent a new line to the same depth as the previous line. The fStream.autoIndent boolean property sets whether auto indent should be applied (true) or not (false). The ttautoindent macro also achieves this.
The Stream Properties toolbar features an icon to toggle this property for the current stream:
fDisplay Yellow Bar Stream Representation
This release sees the introduction of the fDisplay.editStream object. The fTemplate.editBarStream property was introduced in 12.0.0.0, so this can be used to open a tag in the yellow bar. The fDisplay.editStream object represents this stream in the user interface, that which is open in the yellow bar, and is handled by the fdEditStream object. This object can be used to interrogate what the cursor is doing as well as setting the cursor position. the fdEditStream object has the following properties:
fdEditStream.source — the fStream object which is open in the yellow bar
fdEditStream.position — the character number of the cursor position (getvar 21522 or cursor.stream.position)
fdEditStream.numChars — the number of characters selected (getvar 21523 or cursor.stream.selected.count)
fdEditStream.selectedChars — the actual characters which are selected (getvar 11524 or cursor.stream.selected.text)
fdEditStream.viewStartPosition and fdEditStream.viewEndPosition — the positions of the first and last characters visible in the yellow bar (getvars 21528 and 21529 or editbar.pos.start and editbar.pos.end
fdEditStream.xmlNode — if the stream in the yellow bar is XML, this will return an fxNode object for the current node based on where the cursor is
The fdEditStream object also has two methods:
fdEditStream.setCursorPos() — this method can take one or two parameters. The first is an integer for the character position to move the cursor to. The second is optional and if provided should specify the end position if text is to be selected
fdEditStream.insertMarkup() — this method allows an insert markup definition to be called at the current cursor position. See the separate documentation for the Insert Markup feature for more information