Code Edit Region Component - Maple Help

Home : Support : Online Help : Programming : Document Tools : Components : Code Edit Region Component

DocumentTools[Components]

 CodeEditRegion
 generate XML for a CodeEditRegion Component

 Calling Sequence CodeEditRegion(str, opts)

Parameters

 str - (optional) string; string of code statements. opts - (optional) ; one or more keyword options as described below

Options

 • autoexpand : truefalse; Indicates whether the component will expand automatically. The default is true.
 • expanded : truefalse; Indicates whether the component is expanded. The default is true.
 • height : posint; The height in pixels of the component. The default value is 200.
 • identity : {name,string}; The reference name of the component.
 • linenumbers : truefalse; Indicates whether the code is annotated with line numbers. The default is true.
 • showborders : truefalse; Indicates whether the component's borders are shown. The default is true.
 • visible : truefalse; Indicates whether the component is visible. The default is true.
 • width  : posint; The width in pixels of the component. The default value is 500.

Description

 • The CodeEditRegion command in the Component Constructors package returns an XML function call which represents a CodeEditRegion Component.
 • The generated XML can be used with the results of commands in the Layout Constructors package to create an entire Worksheet or Document in XML form. Such a representation of a Worksheet or Document can be inserted into the current document using the InsertContent command.

Examples

 > $\mathrm{with}\left(\mathrm{DocumentTools}\right):$
 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Components}\right):$
 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Layout}\right):$
 > $s≔"x := 4;"$
 ${s}{≔}{"x := 4;"}$ (1)

Executing the CodeEditRegion command produces a function call.

 > $C≔\mathrm{CodeEditRegion}\left(s,\mathrm{identity}="CodeEditRegion0"\right)$
 ${C}{≔}{\mathrm{_XML_CodeEditor-ExecGroup}}{}\left({"view"}{=}{"presentation"}{,}{"applyint"}{=}{"false"}{,}{"applyrational"}{=}{"false"}{,}{"display"}{=}{"code"}{,}{\mathrm{_XML_EC-CodeEditor}}{}\left({"id"}{=}{"CodeEditRegion0"}{,}{"pixel-width"}{=}{"500"}{,}{"pixel-height"}{=}{"200"}{,}{"autoexpand"}{=}{"true"}{,}{"expanded"}{=}{"true"}{,}{"visible"}{=}{"true"}{,}{"code-line-numbers"}{=}{"true"}{,}{"wrapping"}{=}{"false"}{,}{"show-border"}{=}{"true"}{,}{"x := 4;"}\right)\right)$ (2)

By using commands from the DocumentTools:-Layout package a nested function call can be produced which represents a worksheet.

 > $\mathrm{xml}≔\mathrm{Worksheet}\left(C\right):$

That XML representation of a worksheet can be inserted directly.

 > $\mathrm{InsertContent}\left(\mathrm{xml}\right):$

The previous example's call to the InsertContent command inserted a component with identity "CodeEditRegion0", which still exists in this worksheet. Inserting additional content whose input contains another component with that same identity "CodeEditRegion0" incurs a substitution of the input identity in order to avoid a conflict with the identity of the existing component.

The return value of the following call to InsertContent is a table which can be used to reference the substituted identity of the inserted component.

 > C := CodeEditRegion( s, identity = "CodeEditRegion0",                         width = 400, height = 300, linenumbers=false,                         showborders = false );
 ${C}{≔}{\mathrm{_XML_CodeEditor-ExecGroup}}{}\left({"view"}{=}{"presentation"}{,}{"applyint"}{=}{"false"}{,}{"applyrational"}{=}{"false"}{,}{"display"}{=}{"code"}{,}{\mathrm{_XML_EC-CodeEditor}}{}\left({"id"}{=}{"CodeEditRegion0"}{,}{"pixel-width"}{=}{"400"}{,}{"pixel-height"}{=}{"300"}{,}{"autoexpand"}{=}{"true"}{,}{"expanded"}{=}{"true"}{,}{"visible"}{=}{"true"}{,}{"code-line-numbers"}{=}{"false"}{,}{"wrapping"}{=}{"false"}{,}{"show-border"}{=}{"false"}{,}{"x := 4;"}\right)\right)$ (3)
 > xml := Worksheet( C ):
 > lookup := InsertContent(xml, output=table);
 ${\mathrm{lookup}}{≔}{table}{}\left(\left[{"CodeEditRegion0"}{=}{"CodeEditRegion1"}\right]\right)$ (4)

 > lookup["CodeEditRegion0"];
 ${"CodeEditRegion1"}$ (5)
 > GetProperty( lookup["CodeEditRegion0"], value );
 ${"x := 4;"}$ (6)
 >

Compatibility

 • The DocumentTools:-Components:-CodeEditRegion command was introduced in Maple 2015.