Loading...
 

CodeEditor

CodeEditor (WebWidget)

The CodeEditor offers the possibility to edit and automatically format code snippets of different programming and scripting languages to increase the readability of the code and enable productive code editing and better code understanding. Features such as error detection, automatic correction and the expansion of the supported programming and scripting languages are planned.

To tell the CodeEditor which formatting rules it has to apply, so-called modes are defined, which contain one or more programming or scripting languages. Usually one mode corresponds to a single programming or scripting language, but there are often cases where a code snippet contains several scripting and programming languages (CX_FORMULA with InstantView code, HTML with CSS and JavaScript, ... etc)

The CodeEditor WebWidget
The CodeEditor WebWidget

Use

Web(codeEditor, APP("codeEditor.html"), 0, 0, 800, 600)

Dependencies

  • codeEditor.html
  • codeEditor-directive.js
  • standalone/code editor/

Message interface

When describing the direction, the WebWidget is divided into its two components. The WebWidget implemented in HTML, which implements the presentation logic and user interaction in the browser, and the WebWidget implemented in InstantView, which supplies the other side with the data from ClassiX and controls it.

Name Parameters Description
Push News (IV→HTML)
action Action This message passes an action object to the Web widget as CX_JSON_OBJECT, thereby performing an action on InstantView's CodeEditor, such as formatting the code or returning the current text in the CodeEditor to InstantView.
data Data This message passes a data object to the Web widget as CX_JSON_OBJECT and specifies the value of the code editor (the source code) and other relevant settings.
Events (HTML→IV)
INITIALIZE_SOCKET - The first message that the WebWidget sends once it has initialized. This indicates that the WebWidget is ready to receive and process push messages.
SAVE_DATA_SOCKET String Is fired in response to an action message with the action "saveData" and contains the current text of the CodeEditor as value.

The data object

The data object is of type CX_JSON_OBJECT and determines the value of the code editor (the source code) and other relevant settings.

Field Type Default value Description
text String "" The source code to edit and format.
fashion String "CX_FORMULA" The name of the mode to apply (the scripting or programming language(s) whose formatting and validation rules are to be applied). Currently the following modes are supported: "CX_FORMULA", InstantView", "clike" and "javascript".
format Boolean true If set to false, the transmitted code is not automatically formatted, which would otherwise be the case.

The Action Object

The action object is of type CX_JSON_OBJECT and always has an actionId field that takes a string representing a particular action. Depending on the action, additional parameters may be required.

Action ID Parameters Description
"format" none

Formatting the current code

Formats the current code in the CodeEditor according to the formatting rules of the selected mode.

"saveData" none

SaveData

This action fires the message SAVE_DATA_SOCKET to transfer the (edited) source code from the CodeEditor to ClassiX.

Note: After sending this action message, the ClassiX system does not wait for the response, but continues to process possible further InstantView instructions. The response message SAVE_DATA_SOCKET with the value of the CodeEditor thus arrives asynchronously. If further processing of the InstantView statements should depend on the value of the code editor, you can use the WaitOnInput mechanism.