Doc is the model for text edited in a TextEditor
Slots
-
internal Int? bracketCol1
-
internal Int? bracketCol2
-
internal Int? bracketLine1
-
internal Int? bracketLine2
-
internal Int caretLine
- charCountSource
-
override Int charCount()
Overrides fwt::RichTextModel.charCount
Doc inherited from fwt::RichTextModel.charCount
Return the number of characters in the content.
-
internal Str delimiter
- dumpSource
-
Void dump(OutStream out := Sys.out())
Debug dump of the document model.
- findNextSource
-
Int? findNext(Str s, Int offset, Bool matchCase)
Find the specified string in the document starting the search at the document offset and looking forward. Return null is not found. Note we don't currently support searching across multiple lines.
- findPrevSource
-
Int? findPrev(Str s, Int offset, Bool matchCase)
Find the specified string in the document starting the search at the document offset and looking backward. Return null is not found. Note we don't currently support searching across multiple lines.
-
private Void insertBracketMatch(Obj[] styling, Int offset, Int lineLen)
Insert a bracket match style run of one character at the specified offset. There are four cases where "xxx" is run, and "^" is insertion point:
x a) replace single char run
xxx b) insert at end xxx c) move run to right one char, insert xxxxx d) breaking middle of run ^
- lineSource
-
override Str line(Int lineIndex)
Overrides fwt::RichTextModel.line
Doc inherited from fwt::RichTextModel.line
Return the line at the given zero based line index without delimiters.
- lineAtOffsetSource
-
override Int lineAtOffset(Int offset)
Overrides fwt::RichTextModel.lineAtOffset
Doc inherited from fwt::RichTextModel.lineAtOffset
Return the zero based line index at the given character offset.
- lineBackgroundSource
-
override Color? lineBackground(Int lineIndex)
Overrides fwt::RichTextModel.lineBackground
Doc inherited from fwt::RichTextModel.lineBackground
Return the color to use for the specified line's background. Normal lineStyling backgrounds only cover the width of the text. However, the lineBackground covers the width of the entire edit area. Return null for no special background.
- lineCountSource
-
override Int lineCount()
Overrides fwt::RichTextModel.lineCount
Doc inherited from fwt::RichTextModel.lineCount
Return the number of lines.
- lineStylingSource
-
override Obj[]? lineStyling(Int lineIndex)
Overrides fwt::RichTextModel.lineStyling
Doc inherited from fwt::RichTextModel.lineStyling
Return the styled segments for the given zero based line index. The result is a list of Int/RichTextStyle pairs where the Int specifies a zero based char offset of the line using a pattern such as:
[Int, RichTextStyle, Int, RichTextStyle, ...]
-
internal Line[] lines := Line[,]
-
internal Void load(Str[] strLines)
Load fresh document already parsed into lines.
- makeSource
-
new make(TextEditorOptions options, SyntaxOptions syntax, SyntaxRules rules)
-
internal Int? matchBracket(Int offset)
Attempt to find the matching bracket the specified offset. If the bracket is an opening bracket then we search forward for the closing bracket taking into account nesting. If a closing bracket we search backward. Return null if no match.
- modifySource
-
override Void modify(Int startOffset, Int len, Str newText)
Overrides fwt::RichTextModel.modify
Doc inherited from fwt::RichTextModel.modify
Replace the text with
newText
starting at positionstart
for a length ofreplaceLen
. The model implementation must fire the onModify event. - offsetAtLineSource
-
override Int offsetAtLine(Int lineIndex)
Overrides fwt::RichTextModel.offsetAtLine
Doc inherited from fwt::RichTextModel.offsetAtLine
Return the character offset of the first character of the given zero based line index.
- optionsSource
-
readonly TextEditorOptions options
-
internal Parser parser
- rulesSource
-
readonly SyntaxRules rules
-
internal Void save(OutStream out)
Save document to output stream (we assume charset is already configured).
-
internal Void setBracketMatch(Int line1, Int col1, Int line2, Int col2)
Set the two current matching bracket positions. These will get styled specially. It is up to the caller to repaint the dirty lines.
-
internal Int size := 0
- syntaxSource
-
readonly SyntaxOptions syntax
- textSource
-
override Str text
Overrides fwt::RichTextModel.text
Doc inherited from fwt::RichTextModel.text
Get or set the entire text document.
-
private Void updateLines(Line[] lines)
Walk all the lines:
- update offset
- update total size
- compute style override for block comments
- compute style override for multiline strings
-
internal Void updateMarks(Mark[] marks)
Highlight all the marks found in this document.