Interface ICodeeditor
-
- All Superinterfaces:
IAnyGroup<ICodeeditor>,IComponent<ICodeeditor>,IDisable<ICodeeditor>,IHtmlBasedComponent<ICodeeditor>,IReadonly<ICodeeditor>,IXulElement<ICodeeditor>
public interface ICodeeditor extends IXulElement<ICodeeditor>, IDisable<ICodeeditor>, IReadonly<ICodeeditor>, IAnyGroup<ICodeeditor>
ImmutableCodeeditorcomponent.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 anonChange/onChanginghandler, or pull it into any other action with@Action(type = Events.ON_CLICK) public void save(@ActionVariable(targetId = ActionTarget.SELF, field = "value") String value) { }valueis the only editor state the client reports.- Since:
- 11.0.0
- Author:
- peaker
- See Also:
Codeeditor
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classICodeeditor.BuilderBuilds instances of typeICodeeditor.static classICodeeditor.UpdaterBuilds an updater of typeICodeeditorforUiAgent.smartUpdate(Locator, SmartUpdater).
-
Field Summary
Fields Modifier and Type Field Description static ICodeeditorDEFAULTConstant for default attributes of this immutable component.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.lang.StringgetColorScheme()Returns the editor color scheme, or null when it was reset to the default.default java.lang.StringgetLanguage()Returns the syntax-highlight language, or null when it was reset to the default.default intgetTabSize()Returns the number of columns a tab character is rendered as.default java.lang.StringgetValue()Returns the editor content.default java.lang.StringgetWidgetClass()Returns the client widget class.default booleanisLineNumbers()Returns whether the gutter line numbers are shown.static ICodeeditorof(java.lang.String value)Returns the instance with the given content.static ICodeeditorofId(java.lang.String id)Returns the instance with the given id.ICodeeditorwithColorScheme(java.lang.String colorScheme)Returns a copy ofthisimmutable component with the specifiedcolorScheme.ICodeeditorwithLanguage(java.lang.String language)Returns a copy ofthisimmutable component with the specifiedlanguage.ICodeeditorwithLineNumbers(boolean lineNumbers)Returns a copy ofthisimmutable component with the specifiedlineNumbers.ICodeeditorwithTabSize(int tabSize)Returns a copy ofthisimmutable component with the specifiedtabSize.ICodeeditorwithValue(java.lang.String value)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, withWidgetOverrides
-
Methods inherited from interface org.zkoss.stateless.sul.IDisable
isDisabled, withDisabled
-
Methods 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, withZIndex
-
Methods inherited from interface org.zkoss.stateless.sul.IReadonly
isReadonly, withReadonly
-
Methods inherited from interface org.zkoss.stateless.sul.IXulElement
getContext, getCtrlKeys, getPopup, getTooltip, withContext, withCtrlKeys, withPopup, withTooltip
-
-
-
-
Field Detail
-
DEFAULT
static final ICodeeditor DEFAULT
Constant for default attributes of this immutable component.
-
-
Method Detail
-
getWidgetClass
default java.lang.String getWidgetClass()
Returns the client widget class.Default:
"zul.code.Codeeditor"- Specified by:
getWidgetClassin interfaceIComponent<ICodeeditor>
-
getValue
default java.lang.String getValue()
Returns the editor content.Default: an empty string.
-
withValue
ICodeeditor withValue(java.lang.String value)
Returns a copy ofthisimmutable component with the specifiedvalue.Sets the editor content.
- Parameters:
value- the source code.Default:
"".- Returns:
- A modified copy of the
thisobject
-
getLanguage
@Nullable default java.lang.String getLanguage()
Returns the syntax-highlight language, or null when it was reset to the default.Default:
"plain".
-
withLanguage
ICodeeditor withLanguage(@Nullable java.lang.String language)
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
ICodeeditor withLineNumbers(boolean lineNumbers)
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
ICodeeditor withTabSize(int tabSize)
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
@Nullable default java.lang.String getColorScheme()
Returns the editor color scheme, or null when it was reset to the default.Default:
"light".
-
withColorScheme
ICodeeditor withColorScheme(@Nullable java.lang.String colorScheme)
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
static ICodeeditor of(java.lang.String value)
Returns the instance with the given content.- Parameters:
value- The source code to edit
-
ofId
static ICodeeditor ofId(java.lang.String id)
Returns the instance with the given id.- Parameters:
id- The id to identify this component
-
-