Skip to main content

cturtle/ui/btlib/code_editor

include "cturtle/ui/btlib/code_editor";

Types​

TextEditorSyntaxSpan​

Object

FieldTypeWritableDescription
startintyes
lengthintyes
kindintyes

TextDocumentColumns​

Object

FieldTypeWritableDescription
leftintyes
rightintyes

TextDocumentRectangle​

Object

FieldTypeWritableDescription
anchorColumnintyes
cursorColumnintyes
columnsmap<int, TextDocumentColumns>yes
visualboolyes
anchorXfloatyes
cursorXfloatyes

TextDocumentEdit​

Object

FieldTypeWritableDescription
labelstringyes
startLineintyes
beforeLinesarray<string>yes
afterLinesarray<string>yes
beforeCursorLineintyes
beforeCursorColumnintyes
beforeGoalColumnintyes
beforeAnchorLineintyes
beforeAnchorColumnintyes
afterCursorLineintyes
afterCursorColumnintyes
afterGoalColumnintyes
afterAnchorLineintyes
afterAnchorColumnintyes
beforeRectangleTextDocumentRectangleyes
afterRectangleTextDocumentRectangleyes
beforeRevisionintyes
afterRevisionintyes

TextDocumentRange​

Object

FieldTypeWritableDescription
startLineintyes
startColumnintyes
endLineintyes
endColumnintyes

TextDocumentTextEdit​

Object

FieldTypeWritableDescription
startintyes
lengthintyes
replacementstringyes

TextDocumentObserver​

Object

FieldTypeWritableDescription
handlerTextDocumentChangeHandleryes

documentChanged infallible​

infallible fn documentChanged(TextDocument document)

TextDocument​

Object

FieldTypeWritableDescription
syntaxTextMateHighlighteryes
pathstringyes
lineEndingstringyes
linesarray<string>yes
cursorLineintyes
cursorColumnintyes
goalColumnintyes
selectionAnchorLineintyes
selectionAnchorColumnintyes
rectangleTextDocumentRectangleyes
revisionintyes
savedRevisionintyes
nextRevisionintyes
undoStackarray<TextDocumentEdit>yes
redoStackarray<TextDocumentEdit>yes
changeHandlerTextDocumentObserver?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

FieldTypeWritableDescription
editorTextEditoryes

pressed​

fn pressed(Widget widget, float x, float y)

clicked​

fn clicked(Widget widget, float x, float y)

TextEditorPaintState​

Object

FieldTypeWritableDescription
startsarray<int>yes
endsarray<int>yes
syntaxCountsarray<int>yes
linesarray<int>yes
documentTextDocumentyes
firstLineintyes
revisionintyes
cursorLineintyes
visibleRowsintyes
rowOffsetfloatyes
rectangleboolyes
rectangleLeftintyes
rectangleRightintyes
rectangleStateTextDocumentRectangleyes

TextEditorScrollbar​

Object

FieldTypeWritableDescription
trackUiElementyes
thumbUiElementyes
railUiElementyes
gripUiElementyes
trackWidgetWidgetyes
thumbWidgetWidgetyes
visibleboolyes
visibilityInitializedboolyes
draggingboolyes
hoveredboolyes
expandedboolyes
thumbHeightfloatyes
topfloatyes
grabOffsetfloatyes

refreshWidth infallible​

infallible fn refreshWidth()

resetWidth infallible​

infallible fn resetWidth()

TextEditorScrollFrame​

Object

FieldTypeWritableDescription
editorTextEditoryes
generationintyes

apply​

fn apply(UiInputSink sink)

DragTextEditorScrollbar​

Object

FieldTypeWritableDescription
editorTextEditoryes

moved​

fn moved(float x, float y, float dx, float dy)

released​

fn released()

TextEditor​

Object

FieldTypeWritableDescription
libUiLibyes
themeThemeyes
rootUiElementyes
headerUiElementyes
gutterRuleUiElementyes
pathTextUiElementyes
statusTextUiElementyes
rowsUiElementyes
rowContentUiElementyes
scrollbarTextEditorScrollbaryes
caretUiElementyes
findBarUiElementyes
findFaceUiElementyes
findTextUiElementyes
findCaretUiElementyes
findStatusUiElementyes
rowRootsarray<UiElement>yes
rowNumbersarray<UiElement>yes
rowBreakpointsarray<UiElement>yes
rowTextsarray<UiElement>yes
rowSyntaxTextsarray<UiElement>yes
rowSelectionsarray<UiElement>yes
occurrenceBoxesarray<UiElement>yes
occurrenceRangesarray<TextDocumentRange>yes
occurrenceRevisionintyes
occurrenceGenerationintyes
paintTextEditorPaintStateyes
documentTextDocumentyes
changeHandlerTextEditorChangeHandleryes
gutterHandlerTextEditorGutterHandleryes
contextHandlerTextEditorContextHandleryes
occurrenceHandlerTextEditorOccurrenceHandleryes
focusWidgetWidgetyes
findWidgetWidgetyes
findQuerystringyes
firstLineintyes
rowOffsetfloatyes
scrollFrameGenerationintyes
scrollFramePendingboolyes
rowsHeightfloatyes
syntaxLanguageintyes
highlighterTextMateHighlighteryes
focusedboolyes
findFocusedboolyes
readOnlyboolyes
contentInsetfloatyes
headerHeightfloatyes
lastClickTimefloatyes
lastClickXfloatyes
lastClickYfloatyes
wordDragTextDocumentRangeyes
breakpointLinesarray<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

FieldTypeWritableDescription
rootUiElementyes
captionUiElementyes
editorTextEditoryes

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

FieldTypeWritableDescription
groupintyes
scopestringyes

TextMateRule​

Object

FieldTypeWritableDescription
kindintyes
scopestringyes
patternregexyes
endPatternregexyes
capturesarray<TextMateCapture>yes
childrenarray<TextMateRule>yes

TextMateGrammar​

Object

FieldTypeWritableDescription
namestringyes
scopeNamestringyes
extensionsarray<string>yes
rulesarray<TextMateRule>yes
documentjsonyes

TextMateThemeRule​

Object

FieldTypeWritableDescription
selectorstringyes
foregroundColoryes

TextMateTheme​

Object

FieldTypeWritableDescription
rulesarray<TextMateThemeRule>yes
documentsarray<json>yes

color​

fn color(string scope, Color fallback) -> Color

TextMateSpan​

Object

FieldTypeWritableDescription
startintyes
lengthintyes
scopestringyes

TextMateLine​

Object

FieldTypeWritableDescription
spansarray<TextMateSpan>yes
endRuleintyes

TextMateRegistry​

Object

FieldTypeWritableDescription
grammarsarray<TextMateGrammar>yes
scopeThemeTextMateThemeyes
fallbackThemeThemeyes

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

FieldTypeWritableDescription
sourcestringyes
startRuleintyes
lineTextMateLineyes

TextMateHighlighter​

Object

FieldTypeWritableDescription
registryTextMateRegistryyes
grammarIndexintyes
documentRevisionintyes
dirtyLineintyes
lineCachearray<TextMateCachedLine>yes
startsarray<int>yes
endsarray<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