Class CodeTextModel
java.lang.Object
jfx.incubator.scene.control.richtext.model.StyledTextModel
jfx.incubator.scene.control.richtext.model.BasicTextModel
jfx.incubator.scene.control.richtext.model.CodeTextModel
Editable plain text model with optional syntax highlighting for use with the
CodeArea control.
This model supports custom content storage mechanism via BasicTextModel.Content. By default,
the model provides an in-memory storage via its BasicTextModel.InMemoryContent implementation.
- Since:
- 24
-
Nested Class Summary
Nested classes/interfaces declared in class BasicTextModel
BasicTextModel.Content, BasicTextModel.InMemoryContentModifier and TypeClassDescriptionstatic interfaceThis interface describes the underlying storage mechanism for the BasicTextModel.static classThis content provides in-memory storage in anArrayListofStrings.Nested classes/interfaces declared in class StyledTextModel
StyledTextModel.ListenerModifier and TypeClassDescriptionstatic interfaceReceives information about modifications of the model. -
Property Summary
PropertiesTypePropertyDescriptionfinal ObjectProperty<SyntaxDecorator> Syntax decorator applies styling to the plain text stored in the model.Properties declared in class StyledTextModel
redoable, undoableTypePropertyDescriptionfinal ReadOnlyBooleanPropertyThe property describes if it's currently possible to redo the latest change of the content that was undone.final ReadOnlyBooleanPropertyThe property describes if it's currently possible to undo the latest change of the content that was done. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs the CodeTextModel with an in-memory content.Constructs the CodeTextModel with the specified content. -
Method Summary
Modifier and TypeMethodDescriptionfinal ObjectProperty<SyntaxDecorator> Syntax decorator applies styling to the plain text stored in the model.final SyntaxDecoratorGets the value of thedecoratorproperty.final RichParagraphgetParagraph(int index) Returns aRichParagraphat the given model index.final voidSets the value of thedecoratorproperty.Methods declared in class BasicTextModel
applyParagraphStyle, applyStyle, getPlainText, getStyleAttributeMap, insertLineBreak, insertParagraph, insertText, insertTextSegment, isWritable, removeRange, setParagraphStyle, sizeModifier and TypeMethodDescriptionprotected voidapplyParagraphStyle(int index, StyleAttributeMap paragraphAttrs) Applies paragraph styles in the specified paragraph.protected final voidapplyStyle(int index, int start, int end, StyleAttributeMap a, boolean merge) Applies style to the specified text range within a single paragraph.getPlainText(int index) Returns the plain text string for the specified paragraph.getStyleAttributeMap(StyleResolver resolver, TextPos pos, boolean forInsert) Returns theStyleAttributeMapof the character at the specified position'scharIndex.protected voidinsertLineBreak(int index, int offset) Inserts a line break at the specified position.protected voidinsertParagraph(int index, Supplier<Region> generator) Inserts a paragraph that contains a singleRegion.voidinsertText(TextPos p, String text) Inserts text at the specified position.protected intinsertTextSegment(int index, int offset, String text, StyleAttributeMap attrs) This method is called to insert a single styled text segment at the given position.final booleanDetermines whether the model is writable.protected voidremoveRange(TextPos start, TextPos end) Removes the specified text range.protected final voidsetParagraphStyle(int index, StyleAttributeMap a) Replaces the paragraph styles in the specified paragraph.intsize()Returns the number of paragraphs in the model.Methods declared in class StyledTextModel
addListener, applyStyle, clamp, clearUndoRedo, documentProperties, export, exportParagraph, fireChangeEvent, fireStyleChangeEvent, getDataFormatHandler, getDocumentEnd, getEndOfParagraphTextPos, getLineEnding, getMarker, getParagraphLength, getSupportedAttributes, getSupportedDataFormats, handleDocumentProperties, isRedoable, isUndoable, isUndoRedoEnabled, read, redo, redoableProperty, registerDataFormatHandler, removeDataFormatHandler, removeListener, replace, replace, setLineEnding, setUndoRedoEnabled, undo, undoableProperty, versionString, writeModifier and TypeMethodDescriptionfinal voidaddListener(StyledTextModel.Listener listener) Adds aStyledTextModel.Listenerto this model.final voidapplyStyle(TextPos start, TextPos end, StyleAttributeMap attrs, boolean mergeAttributes) Applies the style attributes to the specified range in the document.final TextPosReturns the text position guaranteed to be within the document and paragraph limits.final voidClears the undo-redo stack.This method is called byStyledTextModel.export(TextPos, TextPos, StyledOutput)to ensure that the document properties, if any, are exported.final voidexport(TextPos start, TextPos end, StyledOutput out) Exports the stream ofStyledSegments in the given range to the specifiedStyledOutput.protected final voidexportParagraph(int index, int start, int end, boolean withParAttrs, StyledOutput out) Exports part of the paragraph as a sequence of styled segments.voidfireChangeEvent(TextPos start, TextPos end, int charsTop, int linesAdded, int charsBottom) Fires a text modification event for the given range.voidfireStyleChangeEvent(TextPos start, TextPos end) Fires a style change event for the given range.final DataFormatHandlergetDataFormatHandler(DataFormat format, boolean forExport) Returns aDataFormatHandlerinstance corresponding to the givenDataFormat.final TextPosReturns the text position corresponding to the end of the document.final TextPosgetEndOfParagraphTextPos(int index) Returns a TextPos corresponding to the end of paragraph at the given index.final LineEndingSpecifies the line ending characters.final MarkerReturns theMarkerat the specified position.intgetParagraphLength(int index) Returns the length of text in a paragraph at the specified index.protected Set<StyleAttribute<?>> Returns the set of attributes supported attributes.final List<DataFormat> getSupportedDataFormats(boolean forExport) Returns an immutable list of supported data formats for either export or import operations, in the order of priority - from high to low.protected voidhandleDocumentProperties(Map<String, String> props, boolean completeReplacement) This method is called by any of thereplace()methods when encountering aStyledSegment.Type.DOCUMENT_PROPERTIESsegment.final booleanGets the value of theredoableproperty.final booleanGets the value of theundoableproperty.final booleanIndicates whether undo/redo functionality is enabled.final voidread(StyleResolver r, DataFormat f, InputStream input) Replaces the content of the model with the data read from the input stream, using the specifiedDataFormat.final TextPos[]redo(StyleResolver resolver) Redoes the recent change, if possible, returning an array comprising [start, end] text positions prior to the change.final ReadOnlyBooleanPropertyThe property describes if it's currently possible to redo the latest change of the content that was undone.protected final voidregisterDataFormatHandler(DataFormatHandler h, boolean forExport, boolean forImport, int priority) Registers a format handler for export and/or import operations.protected final voidremoveDataFormatHandler(DataFormat f, boolean forExport, boolean forImport) Removes the data format handler registered previously withStyledTextModel.registerDataFormatHandler(DataFormatHandler, boolean, boolean, int).final voidremoveListener(StyledTextModel.Listener listener) Removes aStyledTextModel.Listenerfrom this model.final TextPosreplace(StyleResolver resolver, TextPos start, TextPos end, String text) Replaces the given range with the provided plain text.final TextPosreplace(StyleResolver resolver, TextPos start, TextPos end, StyledInput input) Replaces the given range with the provided styled text input.final voidsetLineEnding(LineEnding value) Sets the line ending characters.final voidsetUndoRedoEnabled(boolean on) Controls whether undo/redo functionality is enabled.final TextPos[]undo(StyleResolver resolver) Undoes the recent change, if possible, returning an array comprising [start, end] text positions prior to the change.final ReadOnlyBooleanPropertyThe property describes if it's currently possible to undo the latest change of the content that was done.protected StringThis method is called byStyledTextModel.export(TextPos, TextPos, StyledOutput)to export the model's version string, if any.final voidwrite(StyleResolver r, DataFormat f, OutputStream out) Writes the model content to the output stream using the specifiedDataFormat.
-
Property Details
-
decorator
Syntax decorator applies styling to the plain text stored in the model.- See Also:
-
-
Constructor Details
-
CodeTextModel
public CodeTextModel()Constructs the CodeTextModel with an in-memory content. -
CodeTextModel
Constructs the CodeTextModel with the specified content.- Parameters:
c- the content
-
-
Method Details
-
getParagraph
Description copied from class:StyledTextModelReturns aRichParagraphat the given model index. The callers must ensure that the value ofindexis within the valid document range, since doing otherwise might result in an exception or undetermined behavior.This method makes no guarantees that the same paragraph instance will be returned for the same model index.
- Specified by:
getParagraphin classStyledTextModel- Parameters:
index- the paragraph index in the range (0...StyledTextModel.size())- Returns:
- the instance of
RichParagraph
-
decoratorProperty
Syntax decorator applies styling to the plain text stored in the model.- Returns:
- the syntax decorator value (may be null)
- See Also:
-
getDecorator
Gets the value of thedecoratorproperty.- Property description:
- Syntax decorator applies styling to the plain text stored in the model.
- Returns:
- the value of the
decoratorproperty - See Also:
-
setDecorator
Sets the value of thedecoratorproperty.- Property description:
- Syntax decorator applies styling to the plain text stored in the model.
- Parameters:
d- the value for thedecoratorproperty- See Also:
-