Interface ICodeeditor
- All Superinterfaces:
IAnyGroup<ICodeeditor>,IComponent<ICodeeditor>,IDisable<ICodeeditor>,IHtmlBasedComponent<ICodeeditor>,IReadonly<ICodeeditor>,IXulElement<ICodeeditor>
Codeeditor component.
A code editor that loads and edits source code with syntax highlighting.
Support @Action
| Name | Action Type |
|---|---|
| onChange | ActionData: InputData
Denotes the editor content has been modified by the user. |
| onChanging | ActionData: InputData
Denotes that the user is changing the editor content. |
Reading the edited content
There is no server-side copy of the editor content to read back: the content
travels with an action. Take it from InputData.getValue() on an
onChange/onChanging handler, or pull it into any other action with
@Action(type = Events.ON_CLICK)
public void save(@ActionVariable(targetId = ActionTarget.SELF, field = "value") String value) {
}
value is the only editor state the client reports.- Since:
- 11.0.0
- Author:
- peaker
- See Also:
-
Codeeditor
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classBuilds instances of typeICodeeditor.static classBuilds an updater of typeICodeeditorforUiAgent.smartUpdate(Locator, SmartUpdater). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ICodeeditorConstant for default attributes of this immutable component. -
Method Summary
Modifier and TypeMethodDescriptiondefault StringReturns the editor color scheme, or null when it was reset to the default.default StringReturns the syntax-highlight language, or null when it was reset to the default.default intReturns the number of columns a tab character is rendered as.default StringgetValue()Returns the editor content, or null when it was reset to the default.default StringReturns the client widget class.default booleanReturns whether the gutter line numbers are shown.static ICodeeditorReturns the instance with the given content.static ICodeeditorReturns the instance with the given id.withColorScheme(String colorScheme) Returns a copy ofthisimmutable component with the specifiedcolorScheme.withLanguage(String language) Returns a copy ofthisimmutable component with the specifiedlanguage.withLineNumbers(boolean lineNumbers) Returns a copy ofthisimmutable component with the specifiedlineNumbers.withTabSize(int tabSize) Returns a copy ofthisimmutable component with the specifiedtabSize.Returns a copy ofthisimmutable component with the specifiedvalue.Methods inherited from interface org.zkoss.stateless.sul.IComponent
getAction, getActions, getClientAttributes, getId, getMold, getWidgetListeners, getWidgetOverrides, isVisible, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withActions, withActions, withClientAttribute, withClientAttributes, withId, withMold, withVisible, withWidgetClass, withWidgetListener, withWidgetListeners, withWidgetOverride, withWidgetOverridesMethods inherited from interface org.zkoss.stateless.sul.IDisable
isDisabled, withDisabledMethods inherited from interface org.zkoss.stateless.sul.IHtmlBasedComponent
getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZIndex, isFocus, withClientAction, withDraggable, withDroppable, withFocus, withHeight, withHflex, withLeft, withRenderdefer, withSclass, withSkeleton, withStyle, withTabindex, withTabindex, withTooltiptext, withTop, withVflex, withWidth, withZclass, withZIndexMethods inherited from interface org.zkoss.stateless.sul.IReadonly
isReadonly, withReadonlyMethods inherited from interface org.zkoss.stateless.sul.IXulElement
getContext, getCtrlKeys, getPopup, getTooltip, withContext, withCtrlKeys, withPopup, withTooltip
-
Field Details
-
DEFAULT
Constant for default attributes of this immutable component.
-
-
Method Details
-
getWidgetClass
Returns the client widget class.Default:
"zul.code.Codeeditor"- Specified by:
getWidgetClassin interfaceIComponent<ICodeeditor>
-
getValue
Returns the editor content, or null when it was reset to the default.Default: an empty string.
-
withValue
Returns a copy ofthisimmutable component with the specifiedvalue.Sets the editor content.
- Parameters:
value- the source code, or null to reset to the default, asCodeeditor.setValue(String)does.Default:
"".- Returns:
- A modified copy of the
thisobject
-
getLanguage
Returns the syntax-highlight language, or null when it was reset to the default.Default:
"plain". -
withLanguage
Returns a copy ofthisimmutable component with the specifiedlanguage.Sets the syntax-highlight language.
- Parameters:
language- one ofplain,html,xml,java,javascript,css,json,sql,markdown.Default:
"plain".- Returns:
- A modified copy of the
thisobject - Throws:
org.zkoss.zk.ui.WrongValueException- iflanguageis not an accepted token.
-
isLineNumbers
default boolean isLineNumbers()Returns whether the gutter line numbers are shown.Default:
true. -
withLineNumbers
Returns a copy ofthisimmutable component with the specifiedlineNumbers.Sets whether the gutter line numbers are shown.
- Parameters:
lineNumbers- whether to show the line-number gutter.Default:
true.- Returns:
- A modified copy of the
thisobject
-
getTabSize
default int getTabSize()Returns the number of columns a tab character is rendered as.Default:
4. -
withTabSize
Returns a copy ofthisimmutable component with the specifiedtabSize.Sets how many columns a tab character is rendered as. The indent character itself is always a tab; this only changes its displayed width.
- Parameters:
tabSize- a positive column count.Default:
4.- Returns:
- A modified copy of the
thisobject - Throws:
org.zkoss.zk.ui.WrongValueException- iftabSizeis less than 1.
-
getColorScheme
Returns the editor color scheme, or null when it was reset to the default.Default:
"light". -
withColorScheme
Returns a copy ofthisimmutable component with the specifiedcolorScheme.Sets the editor color scheme. This is the editor's own light/dark surface, not the page theme selected through
Themes.- Parameters:
colorScheme- either"light"or"dark".Default:
"light".- Returns:
- A modified copy of the
thisobject - Throws:
org.zkoss.zk.ui.WrongValueException- ifcolorSchemeis neither.
-
of
Returns the instance with the given content.- Parameters:
value- The source code to edit
-
ofId
Returns the instance with the given id.- Parameters:
id- The id to identify this component
-