Class Codeeditor
- All Implemented Interfaces:
Serializable,Cloneable,org.zkoss.zk.ui.Component,org.zkoss.zk.ui.ext.Disable,org.zkoss.zk.ui.ext.Readonly,org.zkoss.zk.ui.ext.Scope,org.zkoss.zk.ui.sys.ComponentCtrl
The Community Edition build provides basic editing: setting/loading the
content (setValue(java.lang.String)), choosing the highlight language
(setLanguage(java.lang.String)), toggling read-only (isReadonly()) and line
numbers (setLineNumbers(boolean)), and an optional light/dark editor color
scheme (setColorScheme(java.lang.String)). Edits are reported to the server through the
standard onChange/onChanging events carrying an
InputEvent, so value participates in data binding the same way
as other input components.
Advanced capabilities (autocomplete, lint, code folding, multi-cursor, search/replace, diff) are not part of the CE build; they are layered on by the EE module through a client-side extension hook, so an application can adopt them later without changing the component or the ZUL.
- Since:
- 11.0.0
- Author:
- peakerlee
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zk.ui.HtmlBasedComponent.ExtraCtrlNested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.AbstractComponent.Children, org.zkoss.zk.ui.AbstractComponent.ForwardInfo, org.zkoss.zk.ui.AbstractComponent.TargetInfo -
Field Summary
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclassFields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPEFields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the editor color scheme.Returns the syntax-highlight language.intReturns the number of columns a tab character is rendered as.getValue()Returns the editor content.protected booleanbooleanReturns whether the editor is disabled.booleanReturns whether the gutter line numbers are shown.booleanReturns whether the editor is read-only.protected voidrenderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) voidservice(org.zkoss.zk.au.AuRequest request, boolean everError) voidsetColorScheme(String colorScheme) Sets the editor color scheme.voidsetDisabled(boolean disabled) Sets whether the editor is disabled.voidsetLanguage(String language) Sets the syntax-highlight language.voidsetLineNumbers(boolean lineNumbers) Sets whether the gutter line numbers are shown.voidsetReadonly(boolean readonly) Sets whether the editor is read-only.voidsetTabSize(int tabSize) Sets how many columns a tab character is rendered as.voidSets the editor content.Methods inherited from class org.zkoss.zul.impl.XulElement
clone, getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributesMethods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setSkeleton, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectlyMethods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getStubonlyDescendants, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, insertBefore, invalidate, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setStubonlyDescendants, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
Constructor Details
-
Codeeditor
public Codeeditor() -
Codeeditor
-
-
Method Details
-
getValue
Returns the editor content.Default: an empty string.
-
setValue
Sets the editor content.- Parameters:
value- the source code;nullis treated as an empty string.- Since:
- 11.0.0
-
getLanguage
Returns the syntax-highlight language.Default:
"plain". -
setLanguage
Sets the syntax-highlight language.- Parameters:
language- one ofplain,html,xml,java,javascript,css,json,sql,markdown;nullresets it to the default"plain".- Throws:
org.zkoss.zk.ui.WrongValueException- iflanguageis non-null and not an accepted token.- Since:
- 11.0.0
-
isReadonly
public boolean isReadonly()Returns whether the editor is read-only.Default: false.
- Specified by:
isReadonlyin interfaceorg.zkoss.zk.ui.ext.Readonly
-
setReadonly
public void setReadonly(boolean readonly) Sets whether the editor is read-only.- Specified by:
setReadonlyin interfaceorg.zkoss.zk.ui.ext.Readonly- Parameters:
readonly- whether to forbid editing the content.- Since:
- 11.0.0
-
isDisabled
public boolean isDisabled()Returns whether the editor is disabled.Default: false.
- Specified by:
isDisabledin interfaceorg.zkoss.zk.ui.ext.Disable
-
setDisabled
public void setDisabled(boolean disabled) Sets whether the editor is disabled. A disabled editor cannot be edited or focused and is shown dimmed; unlikesetReadonly(boolean), which keeps the content focusable and selectable.- Specified by:
setDisabledin interfaceorg.zkoss.zk.ui.ext.Disable- Parameters:
disabled- whether to disable the editor.- Since:
- 11.0.0
-
isLineNumbers
public boolean isLineNumbers()Returns whether the gutter line numbers are shown.Default: true.
-
setLineNumbers
public void setLineNumbers(boolean lineNumbers) Sets whether the gutter line numbers are shown.- Parameters:
lineNumbers- whether to show the line-number gutter.- Since:
- 11.0.0
-
getTabSize
public int getTabSize()Returns the number of columns a tab character is rendered as.Default: 4.
-
setTabSize
public void setTabSize(int tabSize) 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; the default is 4.- Throws:
org.zkoss.zk.ui.WrongValueException- iftabSizeis less than 1.- Since:
- 11.0.0
-
getColorScheme
Returns the editor color scheme.Default:
"light". -
setColorScheme
Sets the editor color scheme. This is the editor's own light/dark surface, not the page theme selected throughThemes.- Parameters:
colorScheme-lightordark;nullresets it to the default"light".- Throws:
org.zkoss.zk.ui.WrongValueException- ifcolorSchemeis non-null and neitherlightnordark.- Since:
- 11.0.0
-
isChildable
protected boolean isChildable()- Overrides:
isChildablein classorg.zkoss.zk.ui.AbstractComponent
-
renderProperties
- Overrides:
renderPropertiesin classXulElement- Throws:
IOException
-
service
public void service(org.zkoss.zk.au.AuRequest request, boolean everError) - Specified by:
servicein interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
servicein classorg.zkoss.zk.ui.HtmlBasedComponent
-