DocumentTools[Components]
CodeEditRegion
generate XML for a CodeEditRegion Component
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
CodeEditRegion(str, opts)
str
-
(optional) string; string of code statements.
opts
(optional) ; one or more keyword options as described below
autofit : 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.
language : string; Indicates the programming language in which the code is written. The default is "Maple".
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.
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.
with⁡DocumentTools:
with⁡DocumentTools:-Components:
with⁡DocumentTools:-Layout:
s≔x := 4;
Executing the CodeEditRegion command produces a function call.
C≔CodeEditRegion⁡s,identity=CodeEditRegion0
C≔_XML_CodeEditor-ExecGroup⁡view=presentation,applyint=false,applyrational=false,display=code,_XML_EC-CodeEditor⁡id=CodeEditRegion0,pixel-width=500,pixel-height=200,autofit=true,expanded=true,visible=true,code-line-numbers=true,wrapping=false,show-border=true,x := 4;
By using commands from the DocumentTools:-Layout package a nested function call can be produced which represents a worksheet.
xml≔Worksheet⁡C:
That XML representation of a worksheet can be inserted directly.
InsertContent⁡xml:
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≔_XML_CodeEditor-ExecGroup⁡view=presentation,applyint=false,applyrational=false,display=code,_XML_EC-CodeEditor⁡id=CodeEditRegion0,pixel-width=400,pixel-height=300,autofit=true,expanded=true,visible=true,code-line-numbers=false,wrapping=false,show-border=false,x := 4;
xml := Worksheet( C ):
lookup := InsertContent(xml, output=table);
lookup≔table⁡CodeEditRegion0=CodeEditRegion1
lookup["CodeEditRegion0"];
CodeEditRegion1
GetProperty( lookup["CodeEditRegion0"], value );
x := 4;
The DocumentTools:-Components:-CodeEditRegion command was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
The expanded option was introduced in Maple 2017.
The visible option was updated in Maple 2017.
For more information on Maple 2017 changes, see Updates in Maple 2017.
The DocumentTools:-Components:-CodeEditRegion command was updated in Maple 2023.
The string option was introduced in Maple 2023.
For more information on Maple 2023 changes, see Updates in Maple 2023.
See Also
Component Code
Component Constructors
DocumentTools
Embedded Components
Layout Constructors
XMLTools
Download Help Document