cturtle/ui/btlib/code_editor
include "cturtle/ui/btlib/code_editor";
Types
TextEditorSyntaxSpan
Object
| Field | Type | Writable | Description |
|---|---|---|---|
start | int | yes | |
length | int | yes | |
kind | int | yes |
TextDocumentColumns
Object
| Field | Type | Writable | Description |
|---|---|---|---|
left | int | yes | |
right | int | yes |
TextDocumentRectangle
Object
| Field | Type | Writable | Description |
|---|---|---|---|
anchorColumn | int | yes | |
cursorColumn | int | yes | |
columns | map<int, TextDocumentColumns> | yes | |
visual | bool | yes | |
anchorX | float | yes | |
cursorX | float | yes |
TextDocumentEdit
Object
| Field | Type | Writable | Description |
|---|---|---|---|
label | string | yes | |
startLine | int | yes | |
beforeLines | array<string> | yes | |
afterLines | array<string> | yes | |
beforeCursorLine | int | yes | |
beforeCursorColumn | int | yes | |
beforeGoalColumn | int | yes | |
beforeAnchorLine | int | yes | |
beforeAnchorColumn | int | yes | |
afterCursorLine | int | yes | |
afterCursorColumn | int | yes | |
afterGoalColumn | int | yes | |
afterAnchorLine | int | yes | |
afterAnchorColumn | int | yes | |
beforeRectangle | TextDocumentRectangle | yes | |
afterRectangle | TextDocumentRectangle | yes | |
beforeRevision | int | yes | |
afterRevision | int | yes |
TextDocumentRange
Object
| Field | Type | Writable | Description |
|---|---|---|---|
startLine | int | yes | |
startColumn | int | yes | |
endLine | int | yes | |
endColumn | int | yes |
TextDocumentTextEdit
Object
| Field | Type | Writable | Description |
|---|---|---|---|
start | int | yes | |
length | int | yes | |
replacement | string | yes |
TextDocumentObserver
Object
| Field | Type | Writable | Description |
|---|---|---|---|
handler | TextDocumentChangeHandler | yes |
documentChanged infallible
infallible fn documentChanged(TextDocument document)
TextDocument
Object
| Field | Type | Writable | Description |
|---|---|---|---|
syntax | TextMateHighlighter | yes | |
path | string | yes | |
lineEnding | string | yes | |
lines | array<string> | yes | |
cursorLine | int | yes | |
cursorColumn | int | yes | |
goalColumn | int | yes | |
selectionAnchorLine | int | yes | |
selectionAnchorColumn | int | yes | |
rectangle | TextDocumentRectangle | yes | |
revision | int | yes | |
savedRevision | int | yes | |
nextRevision | int | yes | |
undoStack | array<TextDocumentEdit> | yes | |
redoStack | array<TextDocumentEdit> | yes | |
changeHandler | TextDocumentObserver? | yes |
replaceText
fn replaceText(string source)
load
fn load(string path, string source)
dirty infallible
infallible fn dirty() -> bool
markChanged infallible
infallible fn markChanged()
markSaved infallible
infallible fn markSaved()
lineCount infallible
infallible fn lineCount() -> int
canUndo infallible
infallible fn canUndo() -> bool
canRedo infallible
infallible fn canRedo() -> bool
currentLine infallible
infallible fn currentLine() -> string
hasSelection infallible
infallible fn hasSelection() -> bool
clearSelection infallible
infallible fn clearSelection()
selectionRange infallible
infallible fn selectionRange() -> TextDocumentRange
rectangleLeft infallible
infallible fn rectangleLeft() -> int
rectangleRight infallible
infallible fn rectangleRight() -> int
beginRectangle
fn beginRectangle()
setRectangleColumn
fn setRectangleColumn(int column)
rectangleColumns infallible
infallible fn rectangleColumns(int line) -> TextDocumentColumns
selectionOnLine
fn selectionOnLine(int line) -> TextDocumentRange
selectWord
fn selectWord()
selectedText
fn selectedText() -> string
selectAll infallible
infallible fn selectAll()
selectMatch infallible
infallible fn selectMatch(int line, int column, int length)
findForward
fn findForward(string query) -> bool
findBackward
fn findBackward(string query) -> bool
findCount
fn findCount(string query) -> int
findOrdinal
fn findOrdinal(string query) -> int
beginEdit infallible
infallible fn beginEdit(int startLine, int lineCount) -> TextDocumentEdit
finishEdit infallible
infallible fn finishEdit(TextDocumentEdit edit, int lineCount)
replaceLines
fn replaceLines(int startLine, int removeCount, array<string> replacements)
replaceLine
fn replaceLine(int line, string replacement) -> bool
lineAfterReplacement infallible
infallible fn lineAfterReplacement(
int line,
int startLine,
int removeCount,
int replacementCount) -> int
replaceLineRange
fn replaceLineRange(
int startLine,
int removeCount,
array<string> replacements) -> bool
replaceLineRangeWithLabel
fn replaceLineRangeWithLabel(
int startLine,
int removeCount,
array<string> replacements,
string label) -> bool
applyEdit
fn applyEdit(TextDocumentEdit edit, bool forward)
applyTextEdits
fn applyTextEdits(array<TextDocumentTextEdit> edits, string label) -> bool
undo
fn undo() -> bool
redo
fn redo() -> bool
insert
fn insert(string glyph)
newline
fn newline()
backspace
fn backspace()
deleteForward
fn deleteForward()
replaceRectangle
fn replaceRectangle(string replacement) -> bool
deleteRectangle
fn deleteRectangle(bool backward)
moveWord
fn moveWord(int direction)
deleteWord
fn deleteWord(int direction)
replaceSelection
fn replaceSelection(string replacement) -> bool
moveHorizontal
fn moveHorizontal(int direction)
moveVertical
fn moveVertical(int direction)
home infallible
infallible fn home()
end infallible
infallible fn end()
text
fn text() -> string
PressTextEditor
Object
| Field | Type | Writable | Description |
|---|---|---|---|
editor | TextEditor | yes |
pressed
fn pressed(Widget widget, float x, float y)
clicked
fn clicked(Widget widget, float x, float y)
TextEditorPaintState
Object
| Field | Type | Writable | Description |
|---|---|---|---|
starts | array<int> | yes | |
ends | array<int> | yes | |
syntaxCounts | array<int> | yes | |
lines | array<int> | yes | |
document | TextDocument | yes | |
firstLine | int | yes | |
revision | int | yes | |
cursorLine | int | yes | |
visibleRows | int | yes | |
rowOffset | float | yes | |
rectangle | bool | yes | |
rectangleLeft | int | yes | |
rectangleRight | int | yes | |
rectangleState | TextDocumentRectangle | yes |
TextEditorScrollbar
Object
| Field | Type | Writable | Description |
|---|---|---|---|
track | UiElement | yes | |
thumb | UiElement | yes | |
rail | UiElement | yes | |
grip | UiElement | yes | |
trackWidget | Widget | yes | |
thumbWidget | Widget | yes | |
visible | bool | yes | |
visibilityInitialized | bool | yes | |
dragging | bool | yes | |
hovered | bool | yes | |
expanded | bool | yes | |
thumbHeight | float | yes | |
top | float | yes | |
grabOffset | float | yes |
refreshWidth infallible
infallible fn refreshWidth()
resetWidth infallible
infallible fn resetWidth()
TextEditorScrollFrame
Object
| Field | Type | Writable | Description |
|---|---|---|---|
editor | TextEditor | yes | |
generation | int | yes |
apply
fn apply(UiInputSink sink)
DragTextEditorScrollbar
Object
| Field | Type | Writable | Description |
|---|---|---|---|
editor | TextEditor | yes |
moved
fn moved(float x, float y, float dx, float dy)
released
fn released()
TextEditor
Object
| Field | Type | Writable | Description |
|---|---|---|---|
lib | UiLib | yes | |
theme | Theme | yes | |
root | UiElement | yes | |
header | UiElement | yes | |
gutterRule | UiElement | yes | |
pathText | UiElement | yes | |
statusText | UiElement | yes | |
rows | UiElement | yes | |
rowContent | UiElement | yes | |
scrollbar | TextEditorScrollbar | yes | |
caret | UiElement | yes | |
findBar | UiElement | yes | |
findFace | UiElement | yes | |
findText | UiElement | yes | |
findCaret | UiElement | yes | |
findStatus | UiElement | yes | |
rowRoots | array<UiElement> | yes | |
rowNumbers | array<UiElement> | yes | |
rowBreakpoints | array<UiElement> | yes | |
rowTexts | array<UiElement> | yes | |
rowSyntaxTexts | array<UiElement> | yes | |
rowSelections | array<UiElement> | yes | |
occurrenceBoxes | array<UiElement> | yes | |
occurrenceRanges | array<TextDocumentRange> | yes | |
occurrenceRevision | int | yes | |
occurrenceGeneration | int | yes | |
paint | TextEditorPaintState | yes | |
document | TextDocument | yes | |
changeHandler | TextEditorChangeHandler | yes | |
gutterHandler | TextEditorGutterHandler | yes | |
contextHandler | TextEditorContextHandler | yes | |
occurrenceHandler | TextEditorOccurrenceHandler | yes | |
focusWidget | Widget | yes | |
findWidget | Widget | yes | |
findQuery | string | yes | |
firstLine | int | yes | |
rowOffset | float | yes | |
scrollFrameGeneration | int | yes | |
scrollFramePending | bool | yes | |
rowsHeight | float | yes | |
syntaxLanguage | int | yes | |
highlighter | TextMateHighlighter | yes | |
focused | bool | yes | |
findFocused | bool | yes | |
readOnly | bool | yes | |
contentInset | float | yes | |
headerHeight | float | yes | |
lastClickTime | float | yes | |
lastClickX | float | yes | |
lastClickY | float | yes | |
wordDrag | TextDocumentRange | yes | |
breakpointLines | array<int> | yes |
setOccurrenceHandler infallible
infallible fn setOccurrenceHandler(TextEditorOccurrenceHandler handler)
clearOccurrences infallible
infallible fn clearOccurrences()
setOccurrences
fn setOccurrences(array<TextDocumentRange> ranges)
paintOccurrences
fn paintOccurrences()
setBreakpointLines infallible
infallible fn setBreakpointLines(array<int> lines)
setGutterHandler infallible
infallible fn setGutterHandler(TextEditorGutterHandler handler)
setContextHandler infallible
infallible fn setContextHandler(TextEditorContextHandler handler)
gutterLineAt
fn gutterLineAt(Widget widget, float x, float y) -> int
setHeaderVisible infallible
infallible fn setHeaderVisible(bool visible)
setLineNumbersVisible infallible
infallible fn setLineNumbersVisible(bool visible)
load
fn load(string path, string source)
showDocument
fn showDocument(TextDocument document)
setChangeHandler infallible
infallible fn setChangeHandler(TextEditorChangeHandler handler)
setReadOnly infallible
infallible fn setReadOnly(bool readOnly)
addSyntaxGrammarFile
fn addSyntaxGrammarFile(string grammarPath, array<string> extensions) -> int
addSyntaxGrammarJson
fn addSyntaxGrammarJson(string source, array<string> extensions) -> int
addSyntaxThemeFile
fn addSyntaxThemeFile(string themePath)
addSyntaxThemeJson
fn addSyntaxThemeJson(string source)
clear infallible
infallible fn clear()
setFocused infallible
infallible fn setFocused(bool focused)
editingFind infallible
infallible fn editingFind() -> bool
refreshFindField
fn refreshFindField()
setFindFocused
fn setFindFocused(bool focused)
focusFind
fn focusFind()
showFind
fn showFind()
focus
fn focus()
hideFind
fn hideFind()
findCurrent
fn findCurrent(bool backwards) -> bool
appendFindGlyph
fn appendFindGlyph(string glyph)
removeFindGlyph
fn removeFindGlyph()
viewportHeight infallible
infallible fn viewportHeight() -> float
pageRows infallible
infallible fn pageRows() -> int
scrollOffset infallible
infallible fn scrollOffset() -> float
maximumScrollOffset infallible
infallible fn maximumScrollOffset() -> float
lineAtOffset infallible
infallible fn lineAtOffset(float offset) -> int
maximumFirstLine infallible
infallible fn maximumFirstLine() -> int
setScrollOffset infallible
infallible fn setScrollOffset(float offset)
refreshScrollbar infallible
infallible fn refreshScrollbar()
beginScrollbarDrag infallible
infallible fn beginScrollbarDrag(float y) -> bool
dragScrollbar
fn dragScrollbar(float y)
cancelScrollFrame infallible
infallible fn cancelScrollFrame()
queueScrollFrame infallible
infallible fn queueScrollFrame()
flushScrollFrame
fn flushScrollFrame()
pageScrollbar
fn pageScrollbar(float y)
clampFirstLine infallible
infallible fn clampFirstLine()
visibleRows infallible
infallible fn visibleRows() -> int
setRowsHeight infallible
infallible fn setRowsHeight(float height)
revealCursor infallible
infallible fn revealCursor()
refresh
fn refresh()
refreshSelection
fn refreshSelection()
rotateRows
fn rotateRows(int delta)
paintText
fn paintText(bool reuse)
refreshScrollPosition
fn refreshScrollPosition()
paintSelection
fn paintSelection(bool force)
columnAt
fn columnAt(string line, float target) -> int
columnPixels
fn columnPixels(string line, int column) -> float
virtualColumnAt
fn virtualColumnAt(string line, int column, float target) -> int
setVisualRectangle
fn setVisualRectangle(float anchorX, float cursorX)
pressAt
fn pressAt(Widget widget, float x, float y, int modifiers, float now)
dragAt
fn dragAt(Widget widget, float x, float y)
focusAt
fn focusAt(Widget widget, float x, float y, bool extend)
scroll
fn scroll(float amountY)
keyDown
fn keyDown(int key, int modifiers)
charTyped
fn charTyped(int codepoint)
canUndo infallible
infallible fn canUndo() -> bool
canRedo infallible
infallible fn canRedo() -> bool
hasSelection infallible
infallible fn hasSelection() -> bool
selectedText
fn selectedText() -> string
selectAll
fn selectAll()
deleteSelection
fn deleteSelection() -> bool
paste
fn paste(string text) -> bool
undo
fn undo() -> bool
redo
fn redo() -> bool
TextArea
Object
| Field | Type | Writable | Description |
|---|---|---|---|
root | UiElement | yes | |
caption | UiElement | yes | |
editor | TextEditor | yes |
setText
fn setText(string value)
text
fn text() -> string
setVisible infallible
infallible fn setVisible(bool visible)
setEnabled infallible
infallible fn setEnabled(bool enabled)
TextMateCapture
Object
| Field | Type | Writable | Description |
|---|---|---|---|
group | int | yes | |
scope | string | yes |
TextMateRule
Object
| Field | Type | Writable | Description |
|---|---|---|---|
kind | int | yes | |
scope | string | yes | |
pattern | regex | yes | |
endPattern | regex | yes | |
captures | array<TextMateCapture> | yes | |
children | array<TextMateRule> | yes |
TextMateGrammar
Object
| Field | Type | Writable | Description |
|---|---|---|---|
name | string | yes | |
scopeName | string | yes | |
extensions | array<string> | yes | |
rules | array<TextMateRule> | yes | |
document | json | yes |
TextMateThemeRule
Object
| Field | Type | Writable | Description |
|---|---|---|---|
selector | string | yes | |
foreground | Color | yes |
TextMateTheme
Object
| Field | Type | Writable | Description |
|---|---|---|---|
rules | array<TextMateThemeRule> | yes | |
documents | array<json> | yes |
color
fn color(string scope, Color fallback) -> Color
TextMateSpan
Object
| Field | Type | Writable | Description |
|---|---|---|---|
start | int | yes | |
length | int | yes | |
scope | string | yes |
TextMateLine
Object
| Field | Type | Writable | Description |
|---|---|---|---|
spans | array<TextMateSpan> | yes | |
endRule | int | yes |
TextMateRegistry
Object
| Field | Type | Writable | Description |
|---|---|---|---|
grammars | array<TextMateGrammar> | yes | |
scopeTheme | TextMateTheme | yes | |
fallbackTheme | Theme | yes |
addGrammarJson
fn addGrammarJson(string source, array<string> extensions) -> int
addGrammarFile
fn addGrammarFile(string path, array<string> extensions) -> int
addThemeJson
fn addThemeJson(string source)
addThemeFile
fn addThemeFile(string path)
grammarForPath
fn grammarForPath(string path) -> int
scopeColor
fn scopeColor(string scope) -> Color
TextMateCachedLine
Object
| Field | Type | Writable | Description |
|---|---|---|---|
source | string | yes | |
startRule | int | yes | |
line | TextMateLine | yes |
TextMateHighlighter
Object
| Field | Type | Writable | Description |
|---|---|---|---|
registry | TextMateRegistry | yes | |
grammarIndex | int | yes | |
documentRevision | int | yes | |
dirtyLine | int | yes | |
lineCache | array<TextMateCachedLine> | yes | |
starts | array<int> | yes | |
ends | array<int> | yes |
select
fn select(string path, int revision)
available infallible
infallible fn available() -> bool
invalidateFrom infallible
infallible fn invalidateFrom(int line, int revision)
prepare
fn prepare(array<string> lines)
line
fn line(array<string> lines, int index) -> TextMateLine
color
fn color(string scope) -> Color
Interfaces
TextDocumentChangeHandler
Interface
documentChanged infallible
infallible fn documentChanged(TextDocument document)
TextEditorChangeHandler
Interface
textEditorChanged infallible
infallible fn textEditorChanged()
textEditorSelectionChanged infallible
infallible fn textEditorSelectionChanged()
TextEditorGutterHandler
Interface
textEditorGutterPressed infallible
infallible fn textEditorGutterPressed(int line)
TextEditorContextHandler
Interface
textEditorContextRequested infallible
infallible fn textEditorContextRequested(float x, float y)
TextEditorOccurrenceHandler
Interface
textEditorOccurrencesRequested infallible
infallible fn textEditorOccurrencesRequested(int line, int column)
Functions
textEditorLineHeight infallible
infallible fn textEditorLineHeight() -> float
textEditorHeaderHeight infallible
infallible fn textEditorHeaderHeight() -> float
textEditorGutterWidth infallible
infallible fn textEditorGutterWidth() -> float
textEditorVisibleRows infallible
infallible fn textEditorVisibleRows() -> int
textEditorSyntaxSpansPerRow infallible
infallible fn textEditorSyntaxSpansPerRow() -> int
textEditorSyntaxPlain infallible
infallible fn textEditorSyntaxPlain() -> int
textEditorSyntaxBt infallible
infallible fn textEditorSyntaxBt() -> int
textEditorSyntaxJson infallible
infallible fn textEditorSyntaxJson() -> int
textEditorSyntaxYaml infallible
infallible fn textEditorSyntaxYaml() -> int
textEditorSyntaxShader infallible
infallible fn textEditorSyntaxShader() -> int
textEditorTokenPlain infallible
infallible fn textEditorTokenPlain() -> int
textEditorTokenComment infallible
infallible fn textEditorTokenComment() -> int
textEditorTokenString infallible
infallible fn textEditorTokenString() -> int
textEditorTokenKeyword infallible
infallible fn textEditorTokenKeyword() -> int
textEditorTokenKey infallible
infallible fn textEditorTokenKey() -> int
textEditorTokenNumber infallible
infallible fn textEditorTokenNumber() -> int
textEditorTokenDirective infallible
infallible fn textEditorTokenDirective() -> int
textEditorPathEndsWith
fn textEditorPathEndsWith(string path, string suffix) -> bool
textEditorSyntaxLanguage
fn textEditorSyntaxLanguage(string path) -> int
textEditorSyntaxWordPart infallible
infallible fn textEditorSyntaxWordPart(int c) -> bool
textEditorSyntaxLine
fn textEditorSyntaxLine(int language, string line) -> array<TextEditorSyntaxSpan>
textEditorSyntaxKindAt infallible
infallible fn textEditorSyntaxKindAt(
array<TextEditorSyntaxSpan> spans,
int offset) -> int
textEditorSplitLines
fn textEditorSplitLines(string source) -> array<string>
textDocumentCreate
fn textDocumentCreate(string path, string source) -> TextDocument
textEditorCreate infallible
infallible fn textEditorCreate(UiLib lib, Panel context, Theme theme) -> TextEditor
textAreaCreateIn
fn textAreaCreateIn(
Panel context,
UiElement host,
string caption,
string initial) -> TextArea
textAreaCreate
fn textAreaCreate(Panel context, string caption, string initial) -> TextArea
textMateRegistryCreate infallible
infallible fn textMateRegistryCreate(Theme theme) -> TextMateRegistry
textMateHighlighterCreate infallible
infallible fn textMateHighlighterCreate(
TextMateRegistry registry) -> TextMateHighlighter