| SciTE Lua scripting of edit and output panes using Scintilla API

# Scintilla API calls

Both the edit and output panes are Scintilla controls and can be scripted using Scintilla's API.

The API is presented here as it is called from Lua for the edit pane. All of the same features are available for the output pane by substituting 'output' for 'editor'.

In Lua methods are called with the ':' operator and properties accessed with the '.' operator. Properties are both readable and writeable by default and are otherwise marked "read-only" or "write-only".

The 'position' and 'line' types are integer types that represent positions and line numbers in the document. On 32-bit systems the maximum value is 2,147,483,647 but on 64-bit systems larger values are possible.

The 'pointer' type is a memory address. It is difficult to use this type from Lua but its possible it could be passed back to Scintilla or to an extension written in C.

## Text retrieval and modification

string editor:GetText() -- Retrieve all the text in the document. Returns number of characters retrieved. Result is NUL-terminated.

editor:SetText(string text) -- Replace the contents of the document with the argument text.

editor:SetSavePoint() -- Remember the current position in the undo history as the position at which the document was saved.

string editor:GetLine(line line) -- Retrieve the contents of a line. Returns the length of the line.

editor:ReplaceSel(string text) -- Replace the selected text with the argument text.

bool editor.ReadOnly -- Set to read only or read write.

editor:Allocate(position bytes) -- Enlarge the document to a particular size of text bytes.

line editor.AllocateLines write-only -- Enlarge the number of lines allocated.

editor:AddText(string text) -- Add text to the document at current position.

editor:AppendText(string text) -- Append a string to the end of the document without changing the selection.

editor:InsertText(position pos, string text) -- Insert string at a position.

editor:ChangeInsertion(string text) -- Change the text that is being inserted in response to SC_MOD_INSERTCHECK

editor:ClearAll() -- Delete all text in the document.

editor:DeleteRange(position start, position lengthDelete) -- Delete a range of text in the document.

editor:ClearDocumentStyle() -- Set all style bytes to 0, remove all folding information.

int editor.CharAt[position pos] read-only

int editor.StyleAt[position pos] read-only

int editor.StyleIndexAt[position pos] read-only

editor:ReleaseAllExtendedStyles() -- Release all extended (>255) style numbers

int editor:AllocateExtendedStyles(int numberStyles) -- Allocate some extended (>255) style numbers and return the start of the range

string editor:TargetAsUTF8() -- Returns the target converted to UTF8. Return the length in bytes.

string editor:EncodedFromUTF8(string utf8) -- Translates a UTF8 string into the document encoding. Return the length of the result in bytes. On error return 0.

editor:SetLengthForEncode(position bytes) -- Set the length of the utf8 argument for calling EncodedFromUTF8. Set to -1 and the string will be measured to the first nul.

## Information

position editor.TextLength read-only

position editor.Length read-only

line editor.LineCount read-only

line editor.LinesOnScreen read-only

bool editor.Modify read-only

line editor:LineFromPosition(position pos) -- Retrieve the line containing a position.

position editor:PositionFromLine(line line) -- Retrieve the position at the start of a line.

position editor.LineEndPosition[line line] read-only

position editor:LineLength(line line) -- How many characters are on a line, including end of line characters?

position editor.Column[position pos] read-only

position editor:FindColumn(line line, position column) -- Find the position of a column on a line taking into account tabs and multi-byte characters. If beyond end of line, return line end position.

position editor:PositionBefore(position pos) -- Given a valid document position, return the previous position taking code page into account. Returns 0 if passed 0.

position editor:PositionAfter(position pos) -- Given a valid document position, return the next position taking code page into account. Maximum value returned is the last position in the document.

int editor:TextWidth(int style, string text) -- Measure the pixel width of some text in a particular style. NUL terminated text argument. Does not handle tab or control characters.

int editor:TextHeight(line line) -- Retrieve the height of a particular line of text in pixels.

position editor:PositionFromPoint(int x, int y) -- Find the position from a point within the window.

position editor:PositionFromPointClose(int x, int y) -- Find the position from a point within the window but return INVALID_POSITION if not close to text.

position editor:CharPositionFromPoint(int x, int y) -- Find the position of a character from a point within the window.

position editor:CharPositionFromPointClose(int x, int y) -- Find the position of a character from a point within the window. Return INVALID_POSITION if not close to text.

int editor:PointXFromPosition(position pos) -- Retrieve the x value of the point in the window where a position is displayed.

int editor:PointYFromPosition(position pos) -- Retrieve the y value of the point in the window where a position is displayed.

## By character or UTF-16 code unit

position editor:PositionRelative(position pos, position relative) -- Given a valid document position, return a position that differs in a number of characters. Returned value is always between 0 and last position in document.

position editor:CountCharacters(position start, position end) -- Count characters between two positions.

position editor:PositionRelativeCodeUnits(position pos, position relative) -- Given a valid document position, return a position that differs in a number of UTF-16 code units. Returned value is always between 0 and last position in document. The result may point half way (2 bytes) inside a non-BMP character.

position editor:CountCodeUnits(position start, position end) -- Count code units between two positions.

int editor.LineCharacterIndex read-only

editor:AllocateLineCharacterIndex(int lineCharacterIndex) -- Request line character index be created or its use count increased.

editor:ReleaseLineCharacterIndex(int lineCharacterIndex) -- Decrease use count of line character index and remove if 0.

line editor:LineFromIndexPosition(position pos, int lineCharacterIndex) -- Retrieve the document line containing a position measured in index units.

position editor:IndexPositionFromLine(line line, int lineCharacterIndex) -- Retrieve the position measured in index units at the start of a document line.

## Error handling

int editor.Status -- Change error status - 0 = OK.

## Selection

editor:SetSel(position anchor, position caret) -- Select a range of text.

editor:GotoPos(position caret) -- Set caret to a position and ensure it is visible.

editor:GotoLine(line line) -- Set caret to start of a line and ensure it is visible.

position editor.CurrentPos -- Sets the position of the caret.

position editor.Anchor -- Set the selection anchor to a position. The anchor is the opposite end of the selection from the caret.

position editor.SelectionStart -- Sets the position that starts the selection - this becomes the anchor.

position editor.SelectionEnd -- Sets the position that ends the selection - this becomes the caret.

editor:SetEmptySelection(position caret) -- Set caret to a position, while removing any existing selection.

editor:SelectAll() -- Select all the text in the document.

editor:HideSelection(bool hide) -- Draw the selection either highlighted or in normal (non-highlighted) style.

bool editor.SelectionHidden read-only

string editor:GetSelText() -- Retrieve the selected text. Return the length of the text. Result is NUL-terminated.

string editor:GetCurLine() -- Retrieve the text of the line containing the caret. Returns the index of the caret on the line. Result is NUL-terminated.

bool editor.SelectionIsRectangle read-only

int editor.SelectionMode -- Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or by lines (SC_SEL_LINES).

editor:ChangeSelectionMode(int selectionMode) -- Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or by lines (SC_SEL_LINES) without changing MoveExtendsSelection.

bool editor.MoveExtendsSelection -- Set whether or not regular caret moves will extend or reduce the selection.

position editor:GetLineSelStartPosition(line line) -- Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).

position editor:GetLineSelEndPosition(line line) -- Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).

editor:MoveCaretInsideView() -- Move the caret inside current view if it's not there already.

editor:ChooseCaretX() -- Set the last x chosen value to be the caret x position.

editor:MoveSelectedLinesUp() -- Move the selected lines up one line, shifting the line above after the selection

editor:MoveSelectedLinesDown() -- Move the selected lines down one line, shifting the line below before the selection

bool editor.MouseSelectionRectangularSwitch -- Set whether switching to rectangular mode while selecting with the mouse is allowed.

## Multiple Selection and Virtual Space

bool editor.MultipleSelection -- Set whether multiple selections can be made

bool editor.AdditionalSelectionTyping -- Set whether typing can be performed into multiple selections

int editor.MultiPaste -- Change the effect of pasting when there are multiple selections.

int editor.VirtualSpaceOptions -- Set options for virtual space behaviour.

int editor.RectangularSelectionModifier -- On GTK, allow selecting the modifier key to use for mouse-based rectangular selection. Often the window manager requires Alt+Mouse Drag for moving windows. Valid values are SCMOD_CTRL(default), SCMOD_ALT, or SCMOD_SUPER.

int editor.Selections read-only

bool editor.SelectionEmpty read-only

editor:ClearSelections() -- Clear selections to a single empty stream selection

editor:SetSelection(position caret, position anchor) -- Set a simple selection

editor:AddSelection(position caret, position anchor) -- Add a selection

int editor:SelectionFromPoint(int x, int y) -- Find the selection index for a point. -1 when not at a selection.

editor:DropSelectionN(int selection) -- Drop one selection

int editor.MainSelection -- Set the main selection

position editor.SelectionNCaret[int selection] -- Set the caret position of the nth selection.

position editor.SelectionNCaretVirtualSpace[int selection] -- Set the virtual space of the caret of the nth selection.

position editor.SelectionNAnchor[int selection] -- Set the anchor position of the nth selection.

position editor.SelectionNAnchorVirtualSpace[int selection] -- Set the virtual space of the anchor of the nth selection.

position editor.SelectionNStart[int selection] -- Sets the position that starts the selection - this becomes the anchor.

position editor.SelectionNStartVirtualSpace[int selection] read-only

position editor.SelectionNEnd[int selection] -- Sets the position that ends the selection - this becomes the currentPosition.

position editor.SelectionNEndVirtualSpace[int selection] read-only

position editor.RectangularSelectionCaret -- Set the caret position of the rectangular selection.

position editor.RectangularSelectionCaretVirtualSpace -- Set the virtual space of the caret of the rectangular selection.

position editor.RectangularSelectionAnchor -- Set the anchor position of the rectangular selection.

position editor.RectangularSelectionAnchorVirtualSpace -- Set the virtual space of the anchor of the rectangular selection.

int editor.AdditionalSelAlpha -- Set the alpha of the selection.

colour editor.AdditionalSelFore write-only -- Set the foreground colour of additional selections. Must have previously called SetSelFore with non-zero first argument for this to have an effect.

colour editor.AdditionalSelBack write-only -- Set the background colour of additional selections. Must have previously called SetSelBack with non-zero first argument for this to have an effect.

colour editor.AdditionalCaretFore -- Set the foreground colour of additional carets.

bool editor.AdditionalCaretsBlink -- Set whether additional carets will blink

bool editor.AdditionalCaretsVisible -- Set whether additional carets are visible

editor:SwapMainAnchorCaret() -- Swap that caret and anchor of the main selection.

editor:RotateSelection() -- Set the main selection to the next selection.

editor:MultipleSelectAddNext() -- Add the next occurrence of the main selection to the set of selections as main. If the current selection is empty then select word around caret.

editor:MultipleSelectAddEach() -- Add each occurrence of the main selection in the target to the set of selections. If the current selection is empty then select word around caret.

## Overtype

bool editor.Overtype -- Set to overtype (true) or insert mode.

## Searching

position editor.TargetStart -- Sets the position that starts the target which is used for updating the document without affecting the scroll position.

position editor.TargetStartVirtualSpace -- Sets the virtual space of the target start

position editor.TargetEnd -- Sets the position that ends the target which is used for updating the document without affecting the scroll position.

position editor.TargetEndVirtualSpace -- Sets the virtual space of the target end

editor:SetTargetRange(position start, position end) -- Sets both the start and end of the target in one call.

editor:TargetFromSelection() -- Make the target range start and end be the same as the selection range start and end.

editor:TargetWholeDocument() -- Sets the target to the whole document.

int editor.SearchFlags -- Set the search flags used by SearchInTarget.

position editor:SearchInTarget(string text) -- Search for a counted string in the target and set the target to the found range. Text is counted so it can contain NULs. Returns start of found range or -1 for failure in which case target is not moved.

string editor.TargetText read-only

position editor:ReplaceTarget(string text) -- Replace the target text with the argument text. Text is counted so it can contain NULs. Returns the length of the replacement text.

position editor:ReplaceTargetMinimal(string text) -- Replace the target text with the argument text but ignore prefix and suffix that are the same as current.

position editor:ReplaceTargetRE(string text) -- Replace the target text with the argument text after \d processing. Text is counted so it can contain NULs. Looks for \d where d is between 1 and 9 and replaces these with the strings matched in the last search operation which were surrounded by \( and \). Returns the length of the replacement text including any change caused by processing the \d patterns.

string editor.Tag[int tagNumber] read-only

editor:SearchAnchor() -- Sets the current caret position to be the search anchor.

position editor:SearchNext(int searchFlags, string text) -- Find some text starting at the search anchor. Does not ensure the selection is visible.

position editor:SearchPrev(int searchFlags, string text) -- Find some text starting at the search anchor and moving backwards. Does not ensure the selection is visible.

## Cut, copy and paste

editor:Cut() -- Cut the selection to the clipboard.

editor:Copy() -- Copy the selection to the clipboard.

editor:Paste() -- Paste the contents of the clipboard into the document replacing the selection.

editor:Clear() -- Clear the selection.

bool editor:CanPaste() -- Will a paste succeed?

editor:CopyAllowLine() -- Copy the selection, if selection empty copy the line with the caret

editor:CopyRange(position start, position end) -- Copy a range of text to the clipboard. Positions are clipped into the document.

editor:CopyText(string text) -- Copy argument text to the clipboard.

bool editor.PasteConvertEndings -- Enable/Disable convert-on-paste for line endings

editor:ReplaceRectangular(string text) -- Replace the selection with text like a rectangular paste.

## Undo and Redo

editor:Undo() -- Undo one action in the undo history.

bool editor:CanUndo() -- Are there any undoable actions in the undo history?

editor:Redo() -- Redoes the next action on the undo history.

bool editor:CanRedo() -- Are there any redoable actions in the undo history?

editor:EmptyUndoBuffer() -- Delete the undo history.

bool editor.UndoCollection -- Choose between collecting actions into the undo history and discarding them.

editor:BeginUndoAction() -- Start a sequence of actions that is undone and redone as a unit. May be nested.

editor:EndUndoAction() -- End a sequence of actions that is undone and redone as a unit.

editor:AddUndoAction(int token, int flags) -- Add a container action to the undo stack

## Change history

int editor.ChangeHistory -- Enable or disable change history.

## Scrolling and automatic scrolling

line editor.FirstVisibleLine -- Scroll so that a display line is at the top of the display.

int editor.XOffset -- Set the xOffset (ie, horizontal scroll position).

editor:LineScroll(position columns, line lines) -- Scroll horizontally and vertically.

editor:ScrollCaret() -- Ensure the caret is visible.

editor:ScrollRange(position secondary, position primary) -- Scroll the argument positions and the range between them into view giving priority to the primary position then the secondary position. This may be used to make a search match visible.

editor:SetXCaretPolicy(int caretPolicy, int caretSlop) -- Set the way the caret is kept visible when going sideways. The exclusion zone is given in pixels.

editor:SetYCaretPolicy(int caretPolicy, int caretSlop) -- Set the way the line the caret is on is kept visible. The exclusion zone is given in lines.

editor:SetVisiblePolicy(int visiblePolicy, int visibleSlop) -- Set the way the display area is determined when a particular line is to be moved to by Find, FindNext, GotoLine, etc.

bool editor.HScrollBar -- Show or hide the horizontal scroll bar.

bool editor.VScrollBar -- Show or hide the vertical scroll bar.

int editor.ScrollWidth -- Sets the document width assumed for scrolling.

bool editor.ScrollWidthTracking -- Sets whether the maximum width line displayed is used to set scroll width.

bool editor.EndAtLastLine -- Sets the scroll range so that maximum scroll position has the last line at the bottom of the view (default). Setting this to false allows scrolling one page below the last line.

## White space

int editor.ViewWS -- Make white space characters invisible, always visible or visible outside indentation.

editor:SetWhitespaceFore(bool useSetting, colour fore) -- Set the foreground colour of all whitespace and whether to use this setting.

editor:SetWhitespaceBack(bool useSetting, colour back) -- Set the background colour of all whitespace and whether to use this setting.

int editor.WhitespaceSize -- Set the size of the dots used to mark space characters.

int editor.TabDrawMode -- Set how tabs are drawn when visible.

int editor.ExtraAscent -- Set extra ascent for each line

int editor.ExtraDescent -- Set extra descent for each line

## Cursor

int editor.Cursor -- Sets the cursor to one of the SC_CURSOR* values.

## Mouse capture

bool editor.MouseDownCaptures -- Set whether the mouse is captured when its button is pressed.

bool editor.MouseWheelCaptures -- Set whether the mouse wheel can be active outside the window.

## Line endings

int editor.EOLMode -- Set the current end of line mode.

editor:ConvertEOLs(int eolMode) -- Convert all line endings in the document to one mode.

bool editor.ViewEOL -- Make the end of line characters visible or invisible.

int editor.LineEndTypesSupported read-only

int editor.LineEndTypesAllowed -- Set the line end types that the application wants to use. May not be used if incompatible with lexer or encoding.

int editor.LineEndTypesActive read-only

## Words

position editor:WordEndPosition(position pos, bool onlyWordCharacters) -- Get position of end of word.

position editor:WordStartPosition(position pos, bool onlyWordCharacters) -- Get position of start of word.

bool editor:IsRangeWord(position start, position end) -- Is the range start..end considered a word?

string editor.WordChars -- Set the set of characters making up words for when moving or selecting by word. First sets defaults like SetCharsDefault.

string editor.WhitespaceChars -- Set the set of characters making up whitespace for when moving or selecting by word. Should be called after SetWordChars.

string editor.PunctuationChars -- Set the set of characters making up punctuation characters Should be called after SetWordChars.

editor:SetCharsDefault() -- Reset the set of characters for whitespace and word characters to the defaults.

int editor.CharacterCategoryOptimization -- Set the number of characters to have directly indexed categories

## Styling

position editor.EndStyled read-only

editor:StartStyling(position start, int unused) -- Set the current styling position to start. The unused parameter is no longer used and should be set to 0.

editor:SetStyling(position length, int style) -- Change style from current styling position for length characters to a style and move the current styling position to after this newly styled segment.

editor:SetStylingEx(string styles) -- Set the styles for a segment of the document.

int editor.IdleStyling -- Sets limits to idle styling.

int editor.LineState[line line] -- Used to hold extra styling information for each line.

int editor.MaxLineState read-only

## Style definition

editor:StyleResetDefault() -- Reset the default style to its state at startup

editor:StyleClearAll() -- Clear all the styles and make equivalent to the global default style.

string editor.StyleFont[int style] -- Set the font of a style.

int editor.StyleSize[int style] -- Set the size of characters of a style.

int editor.StyleSizeFractional[int style] -- Set the size of characters of a style. Size is in points multiplied by 100.

bool editor.StyleBold[int style] -- Set a style to be bold or not.

int editor.StyleWeight[int style] -- Set the weight of characters of a style.

bool editor.StyleItalic[int style] -- Set a style to be italic or not.

bool editor.StyleUnderline[int style] -- Set a style to be underlined or not.

colour editor.StyleFore[int style] -- Set the foreground colour of a style.

colour editor.StyleBack[int style] -- Set the background colour of a style.

bool editor.StyleEOLFilled[int style] -- Set a style to have its end of line filled or not.

int editor.StyleCharacterSet[int style] -- Set the character set of the font in a style.

int editor.StyleCase[int style] -- Set a style to be mixed case, or to force upper or lower case.

bool editor.StyleVisible[int style] -- Set a style to be visible or not.

bool editor.StyleChangeable[int style] -- Set a style to be changeable or not (read only). Experimental feature, currently buggy.

bool editor.StyleHotSpot[int style] -- Set a style to be a hotspot or not.

bool editor.StyleCheckMonospaced[int style] -- Indicate that a style may be monospaced over ASCII graphics characters which enables optimizations.

string editor.StyleInvisibleRepresentation[int style] -- Set the invisible representation for a style.

string editor.FontLocale -- Set the locale for displaying text.

## Element colours

editor:SetElementColour(int element, colouralpha colourElement) -- Set the colour of an element. Translucency (alpha) may or may not be significant and this may depend on the platform. The alpha byte should commonly be 0xff for opaque.

colouralpha editor:GetElementColour(int element) -- Get the colour of an element.

editor:ResetElementColour(int element) -- Use the default or platform-defined colour for an element.

bool editor:GetElementIsSet(int element) -- Get whether an element has been set by SetElementColour. When false, a platform-defined or default colour is used.

bool editor:GetElementAllowsTranslucent(int element) -- Get whether an element supports translucency.

colouralpha editor:GetElementBaseColour(int element) -- Get the colour of an element.

## Selection, caret, and hotspot styles

editor:SetSelFore(bool useSetting, colour fore) -- Set the foreground colour of the main and additional selections and whether to use this setting.

editor:SetSelBack(bool useSetting, colour back) -- Set the background colour of the main and additional selections and whether to use this setting.

int editor.SelectionLayer -- Set the layer for drawing selections: either opaquely on base layer or translucently over text

int editor.SelAlpha -- Set the alpha of the selection.

bool editor.SelEOLFilled -- Set the selection to have its end of line filled or not.

colour editor.CaretFore -- Set the foreground colour of the caret.

int editor.CaretLineLayer -- Set the layer of the background of the line containing the caret.

bool editor.CaretLineVisible -- Display the background of the line containing the caret in a different colour.

colour editor.CaretLineBack -- Set the colour of the background of the line containing the caret.

int editor.CaretLineBackAlpha -- Set background alpha of the caret line.

int editor.CaretLineFrame -- Display the caret line framed. Set width != 0 to enable this option and width = 0 to disable it.

bool editor.CaretLineVisibleAlways -- Sets the caret line to always visible.

bool editor.CaretLineHighlightSubLine -- Set only highlighting subline instead of whole line.

int editor.CaretPeriod -- Get the time in milliseconds that the caret is on and off. 0 = steady on.

int editor.CaretStyle -- Set the style of the caret to be drawn.

int editor.CaretWidth -- Set the width of the insert mode caret.

int editor.CaretSticky -- Stop the caret preferred x position changing when the user types.

editor:ToggleCaretSticky() -- Switch between sticky and non-sticky: meant to be bound to a key.

editor:SetHotspotActiveFore(bool useSetting, colour fore) -- Set a fore colour for active hotspots.

colour editor:GetHotspotActiveFore() -- Get the fore colour for active hotspots.

editor:SetHotspotActiveBack(bool useSetting, colour back) -- Set a back colour for active hotspots.

colour editor:GetHotspotActiveBack() -- Get the back colour for active hotspots.

bool editor.HotspotActiveUnderline -- Enable / Disable underlining active hotspots.

bool editor.HotspotSingleLine -- Limit hotspots to single line so hotspots on two lines don't merge.

## Character representations

string editor.Representation[string encodedCharacter] -- Set the way a character is drawn.

editor:ClearRepresentation(string encodedCharacter) -- Remove a character representation.

editor:ClearAllRepresentations() -- Clear representations to default.

int editor.RepresentationAppearance[string encodedCharacter] -- Set the appearance of a representation.

colouralpha editor.RepresentationColour[string encodedCharacter] -- Set the colour of a representation.

int editor.ControlCharSymbol -- Change the way control characters are displayed: If symbol is < 32, keep the drawn way, else, use the given character.

## Margins

int editor.Margins -- Allocate a non-standard number of margins.

int editor.MarginTypeN[int margin] -- Set a margin to be either numeric or symbolic.

int editor.MarginWidthN[int margin] -- Set the width of a margin to a width expressed in pixels.

int editor.MarginMaskN[int margin] -- Set a mask that determines which markers are displayed in a margin.

bool editor.MarginSensitiveN[int margin] -- Make a margin sensitive or insensitive to mouse clicks.

int editor.MarginCursorN[int margin] -- Set the cursor shown when the mouse is inside a margin.

colour editor.MarginBackN[int margin] -- Set the background colour of a margin. Only visible for SC_MARGIN_COLOUR.

int editor.MarginLeft -- Sets the size in pixels of the left margin.

int editor.MarginRight -- Sets the size in pixels of the right margin.

editor:SetFoldMarginColour(bool useSetting, colour back) -- Set one of the colours used as a chequerboard pattern in the fold margin

editor:SetFoldMarginHiColour(bool useSetting, colour fore) -- Set the other colour used as a chequerboard pattern in the fold margin

string editor.MarginText[line line] -- Set the text in the text margin for a line

int editor.MarginStyle[line line] -- Set the style number for the text margin for a line

string editor.MarginStyles[line line] -- Set the style in the text margin for a line

editor:MarginTextClearAll() -- Clear the margin text on all lines

int editor.MarginStyleOffset -- Get the start of the range of style numbers used for margin text

int editor.MarginOptions -- Set the margin options.

## Annotations

string editor.AnnotationText[line line] -- Set the annotation text for a line

int editor.AnnotationStyle[line line] -- Set the style number for the annotations for a line

string editor.AnnotationStyles[line line] -- Set the annotation styles for a line

int editor.AnnotationLines[line line] read-only

editor:AnnotationClearAll() -- Clear the annotations from all lines

int editor.AnnotationVisible -- Set the visibility for the annotations for a view

int editor.AnnotationStyleOffset -- Get the start of the range of style numbers used for annotations

## End of Line Annotations

string editor.EOLAnnotationText[line line] -- Set the end of line annotation text for a line

int editor.EOLAnnotationStyle[line line] -- Set the style number for the end of line annotations for a line

editor:EOLAnnotationClearAll() -- Clear the end of annotations from all lines

int editor.EOLAnnotationVisible -- Set the visibility for the end of line annotations for a view

int editor.EOLAnnotationStyleOffset -- Get the start of the range of style numbers used for end of line annotations

## Other settings

bool editor.BufferedDraw -- If drawing is buffered then each line of text is drawn into a bitmap buffer before drawing it to the screen to avoid flicker.

int editor.PhasesDraw -- In one phase draw, text is drawn in a series of rectangular blocks with no overlap. In two phase draw, text is drawn in a series of lines allowing runs to overlap horizontally. In multiple phase draw, each element is drawn over the whole drawing area, allowing text to overlap from one line to the next.

int editor.Technology -- Set the technology used.

int editor.FontQuality -- Choose the quality level for text from the FontQuality enumeration.

int editor.CodePage -- Set the code page used to interpret the bytes of the document as characters. The SC_CP_UTF8 value can be used to enter Unicode mode.

int editor.IMEInteraction -- Choose to display the IME in a window or inline.

int editor.Bidirectional -- Set bidirectional text display state.

editor:GrabFocus() -- Set the focus to this Scintilla widget.

bool editor.Focus -- Change internal focus flag.

bool editor:SupportsFeature(int feature) -- Get whether a feature is supported

## Brace highlighting

editor:BraceHighlight(position posA, position posB) -- Highlight the characters at two positions.

editor:BraceBadLight(position pos) -- Highlight the character at a position indicating there is no matching brace.

editor:BraceHighlightIndicator(bool useSetting, int indicator) -- Use specified indicator to highlight matching braces instead of changing their style.

editor:BraceBadLightIndicator(bool useSetting, int indicator) -- Use specified indicator to highlight non matching brace instead of changing its style.

position editor:BraceMatch(position pos, int maxReStyle) -- Find the position of a matching brace or INVALID_POSITION if no match. The maxReStyle must be 0 for now. It may be defined in a future release.

position editor:BraceMatchNext(position pos, position startPos) -- Similar to BraceMatch, but matching starts at the explicit start position.

## Tabs and Indentation Guides

int editor.TabMinimumWidth -- Set the minimum visual width of a tab.

int editor.TabWidth -- Change the visible size of a tab to be a multiple of the width of a space character.

editor:ClearTabStops(line line) -- Clear explicit tabstops on a line.

editor:AddTabStop(line line, int x) -- Add an explicit tab stop for a line.

int editor:GetNextTabStop(line line, int x) -- Find the next explicit tab stop position on a line after a position.

bool editor.UseTabs -- Indentation will only use space characters if useTabs is false, otherwise it will use a combination of tabs and spaces.

int editor.Indent -- Set the number of spaces used for one level of indentation.

bool editor.TabIndents -- Sets whether a tab pressed when caret is within indentation indents.

bool editor.BackSpaceUnIndents -- Sets whether a backspace pressed when caret is within indentation unindents.

int editor.LineIndentation[line line] -- Change the indentation of a line to a number of columns.

position editor.LineIndentPosition[line line] read-only

int editor.IndentationGuides -- Show or hide indentation guides.

position editor.HighlightGuide -- Set the highlighted indentation guide column. 0 = no highlighted guide.

## Markers

editor:MarkerDefine(int markerNumber, int markerSymbol) -- Set the symbol used for a particular marker number.

editor:MarkerDefinePixmap(int markerNumber, string pixmap) -- Define a marker from a pixmap.

int editor.RGBAImageWidth write-only -- Set the width for future RGBA image data.

int editor.RGBAImageHeight write-only -- Set the height for future RGBA image data.

int editor.RGBAImageScale write-only -- Set the scale factor in percent for future RGBA image data.

editor:MarkerDefineRGBAImage(int markerNumber, string pixels) -- Define a marker from RGBA data. It has the width and height from RGBAImageSetWidth/Height

int editor:MarkerSymbolDefined(int markerNumber) -- Which symbol was defined for markerNumber with MarkerDefine

colour editor.MarkerFore[int markerNumber] write-only -- Set the foreground colour used for a particular marker number.

colouralpha editor.MarkerForeTranslucent[int markerNumber] write-only -- Set the foreground colour used for a particular marker number.

colour editor.MarkerBack[int markerNumber] write-only -- Set the background colour used for a particular marker number.

colouralpha editor.MarkerBackTranslucent[int markerNumber] write-only -- Set the background colour used for a particular marker number.

colour editor.MarkerBackSelected[int markerNumber] write-only -- Set the background colour used for a particular marker number when its folding block is selected.

colouralpha editor.MarkerBackSelectedTranslucent[int markerNumber] write-only -- Set the background colour used for a particular marker number when its folding block is selected.

int editor.MarkerStrokeWidth[int markerNumber] write-only -- Set the width of strokes used in .01 pixels so 50 = 1/2 pixel width.

editor:MarkerEnableHighlight(bool enabled) -- Enable/disable highlight for current folding block (smallest one that contains the caret)

int editor.MarkerLayer[int markerNumber] -- Set the layer used for a marker that is drawn in the text area, not the margin.

int editor.MarkerAlpha[int markerNumber] write-only -- Set the alpha used for a marker that is drawn in the text area, not the margin.

int editor:MarkerAdd(line line, int markerNumber) -- Add a marker to a line, returning an ID which can be used to find or delete the marker.

editor:MarkerAddSet(line line, int markerSet) -- Add a set of markers to a line.

editor:MarkerDelete(line line, int markerNumber) -- Delete a marker from a line.

editor:MarkerDeleteAll(int markerNumber) -- Delete all markers with a particular number from all lines.

int editor:MarkerGet(line line) -- Get a bit mask of all the markers set on a line.

line editor:MarkerNext(line lineStart, int markerMask) -- Find the next line at or after lineStart that includes a marker in mask. Return -1 when no more lines.

line editor:MarkerPrevious(line lineStart, int markerMask) -- Find the previous line before lineStart that includes a marker in mask.

line editor:MarkerLineFromHandle(int markerHandle) -- Retrieve the line number at which a particular marker is located.

editor:MarkerDeleteHandle(int markerHandle) -- Delete a marker.

int editor:MarkerHandleFromLine(line line, int which) -- Retrieve marker handles of a line

int editor:MarkerNumberFromLine(line line, int which) -- Retrieve marker number of a marker handle

## Indicators

int editor.IndicStyle[int indicator] -- Set an indicator to plain, squiggle or TT.

colour editor.IndicFore[int indicator] -- Set the foreground colour of an indicator.

int editor.IndicStrokeWidth[int indicator] -- Set the stroke width of an indicator in hundredths of a pixel.

int editor.IndicAlpha[int indicator] -- Set the alpha fill colour of the given indicator.

int editor.IndicOutlineAlpha[int indicator] -- Set the alpha outline colour of the given indicator.

bool editor.IndicUnder[int indicator] -- Set an indicator to draw under text or over(default).

int editor.IndicHoverStyle[int indicator] -- Set a hover indicator to plain, squiggle or TT.

colour editor.IndicHoverFore[int indicator] -- Set the foreground hover colour of an indicator.

int editor.IndicFlags[int indicator] -- Set the attributes of an indicator.

int editor.IndicatorCurrent -- Set the indicator used for IndicatorFillRange and IndicatorClearRange

int editor.IndicatorValue -- Set the value used for IndicatorFillRange

editor:IndicatorFillRange(position start, position lengthFill) -- Turn a indicator on over a range.

editor:IndicatorClearRange(position start, position lengthClear) -- Turn a indicator off over a range.

int editor:IndicatorAllOnFor(position pos) -- Are any indicators present at pos?

int editor:IndicatorValueAt(int indicator, position pos) -- What value does a particular indicator have at a position?

position editor:IndicatorStart(int indicator, position pos) -- Where does a particular indicator start?

position editor:IndicatorEnd(int indicator, position pos) -- Where does a particular indicator end?

editor:FindIndicatorShow(position start, position end) -- On macOS, show a find indicator.

editor:FindIndicatorFlash(position start, position end) -- On macOS, flash a find indicator, then fade out.

editor:FindIndicatorHide() -- On macOS, hide the find indicator.

## Autocompletion

editor:AutoCShow(position lengthEntered, string itemList) -- Display a auto-completion list. The lengthEntered parameter indicates how many characters before the caret should be used to provide context.

editor:AutoCCancel() -- Remove the auto-completion list from the screen.

bool editor:AutoCActive() -- Is there an auto-completion list visible?

position editor:AutoCPosStart() -- Retrieve the position of the caret when the auto-completion list was displayed.

editor:AutoCComplete() -- User has selected an item so remove the list and insert the selection.

editor:AutoCStops(string characterSet) -- Define a set of character that when typed cancel the auto-completion list.

int editor.AutoCSeparator -- Change the separator character in the string setting up an auto-completion list. Default is space but can be changed if items contain space.

editor:AutoCSelect(string select) -- Select the item in the auto-completion list that starts with a string.

int editor.AutoCCurrent read-only

string editor.AutoCCurrentText read-only

bool editor.AutoCCancelAtStart -- Should the auto-completion list be cancelled if the user backspaces to a position before where the box was created.

string editor.AutoCFillUps write-only -- Define a set of characters that when typed will cause the autocompletion to choose the selected item.

bool editor.AutoCChooseSingle -- Should a single item auto-completion list automatically choose the item.

bool editor.AutoCIgnoreCase -- Set whether case is significant when performing auto-completion searches.

int editor.AutoCCaseInsensitiveBehaviour -- Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference.

int editor.AutoCMulti -- Change the effect of autocompleting when there are multiple selections.

int editor.AutoCOrder -- Set the way autocompletion lists are ordered.

bool editor.AutoCAutoHide -- Set whether or not autocompletion is hidden automatically when nothing matches.

bool editor.AutoCDropRestOfWord -- Set whether or not autocompletion deletes any word characters after the inserted text upon completion.

int editor.AutoCOptions -- Set autocompletion options.

editor:RegisterImage(int type, string xpmData) -- Register an XPM image for use in autocompletion lists.

editor:RegisterRGBAImage(int type, string pixels) -- Register an RGBA image for use in autocompletion lists. It has the width and height from RGBAImageSetWidth/Height

editor:ClearRegisteredImages() -- Clear all the registered XPM images.

int editor.AutoCTypeSeparator -- Change the type-separator character in the string setting up an auto-completion list. Default is '?' but can be changed if items contain '?'.

int editor.AutoCMaxHeight -- Set the maximum height, in rows, of auto-completion and user lists. The default is 5 rows.

int editor.AutoCMaxWidth -- Set the maximum width, in characters, of auto-completion and user lists. Set to 0 to autosize to fit longest item, which is the default.

## User lists

editor:UserListShow(int listType, string itemList) -- Display a list of strings and send notification when user chooses one.

## Call tips

editor:CallTipShow(position pos, string definition) -- Show a call tip containing a definition near position pos.

editor:CallTipCancel() -- Remove the call tip from the screen.

bool editor:CallTipActive() -- Is there an active call tip?

position editor:CallTipPosStart() -- Retrieve the position where the caret was before displaying the call tip.

position editor.CallTipPosStart write-only -- Set the start position in order to change when backspacing removes the calltip.

editor:CallTipSetHlt(position highlightStart, position highlightEnd) -- Highlight a segment of the definition.

colour editor.CallTipBack write-only -- Set the background colour for the call tip.

colour editor.CallTipFore write-only -- Set the foreground colour for the call tip.

colour editor.CallTipForeHlt write-only -- Set the foreground colour for the highlighted part of the call tip.

int editor.CallTipUseStyle write-only -- Enable use of STYLE_CALLTIP and set call tip tab size in pixels.

bool editor.CallTipPosition write-only -- Set position of calltip, above or below text.

## Key bindings

editor:AssignCmdKey(keymod keyDefinition, int sciCommand) -- When key+modifier combination keyDefinition is pressed perform sciCommand.

editor:ClearCmdKey(keymod keyDefinition) -- When key+modifier combination keyDefinition is pressed do nothing.

editor:ClearAllCmdKeys() -- Drop all key mappings.

editor:Null() -- Null operation.

## Popup edit menu

editor:UsePopUp(int popUpMode) -- Set whether a pop up menu is displayed automatically when the user presses the wrong mouse button on certain areas.

## Macro recording

editor:StartRecord() -- Start notifying the container of all key presses and commands.

editor:StopRecord() -- Stop notifying the container of all key presses and commands.

## Printing

int editor.PrintMagnification -- Sets the print magnification added to the point size of each style for printing.

int editor.PrintColourMode -- Modify colours when printing for clearer printed text.

int editor.PrintWrapMode -- Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).

## Direct access

pointer editor.DirectFunction read-only

pointer editor.DirectStatusFunction read-only

pointer editor.DirectPointer read-only

pointer editor.CharacterPointer read-only

pointer editor:GetRangePointer(position start, position lengthRange) -- Return a read-only pointer to a range of characters in the document. May move the gap so that the range is contiguous, but will only move up to lengthRange bytes.

position editor.GapPosition read-only

## Multiple views

pointer editor.DocPointer -- Change the document object used.

pointer editor:CreateDocument(position bytes, int documentOptions) -- Create a new document object. Starts with reference count of 1 and not selected into editor.

editor:AddRefDocument(pointer doc) -- Extend life of document.

editor:ReleaseDocument(pointer doc) -- Release a reference to the document, deleting document if it fades to black.

int editor.DocumentOptions read-only

## Background loading and saving

pointer editor:CreateLoader(position bytes, int documentOptions) -- Create an ILoader*.

## Folding

line editor:VisibleFromDocLine(line docLine) -- Find the display line of a document line taking hidden lines into account.

line editor:DocLineFromVisible(line displayLine) -- Find the document line of a display line taking hidden lines into account.

editor:ShowLines(line lineStart, line lineEnd) -- Make a range of lines visible.

editor:HideLines(line lineStart, line lineEnd) -- Make a range of lines invisible.

bool editor.LineVisible[line line] read-only

bool editor.AllLinesVisible read-only

int editor.FoldLevel[line line] -- Set the fold level of a line. This encodes an integer level along with flags indicating whether the line is a header and whether it is effectively white space.

int editor.FoldFlags write-only -- Set some style options for folding.

line editor:GetLastChild(line line, int level) -- Find the last child line of a header line.

line editor.FoldParent[line line] read-only

editor:ToggleFold(line line) -- Switch a header line between expanded and contracted.

editor:ToggleFoldShowText(line line, string text) -- Switch a header line between expanded and contracted and show some text after the line.

int editor.FoldDisplayTextStyle -- Set the style of fold display text.

editor:SetDefaultFoldDisplayText(string text) -- Set the default fold display text.

string editor:GetDefaultFoldDisplayText() -- Get the default fold display text.

bool editor.FoldExpanded[line line] -- Show the children of a header line.

editor:FoldLine(line line, int action) -- Expand or contract a fold header.

editor:FoldChildren(line line, int action) -- Expand or contract a fold header and its children.

editor:FoldAll(int action) -- Expand or contract all fold headers.

editor:ExpandChildren(line line, int level) -- Expand a fold header and all children. Use the level argument instead of the line's current level.

int editor.AutomaticFold -- Set automatic folding behaviours.

line editor:ContractedFoldNext(line lineStart) -- Find the next line at or after lineStart that is a contracted fold header line. Return -1 when no more lines.

editor:EnsureVisible(line line) -- Ensure a particular line is visible by expanding any header line hiding it.

editor:EnsureVisibleEnforcePolicy(line line) -- Ensure a particular line is visible by expanding any header line hiding it. Use the currently set visibility policy to determine which range to display.

## Line wrapping

int editor.WrapMode -- Sets whether text is word wrapped.

int editor.WrapVisualFlags -- Set the display mode of visual flags for wrapped lines.

int editor.WrapVisualFlagsLocation -- Set the location of visual flags for wrapped lines.

int editor.WrapIndentMode -- Sets how wrapped sublines are placed. Default is fixed.

int editor.WrapStartIndent -- Set the start indent for wrapped lines.

int editor.LayoutCache -- Sets the degree of caching of layout information.

int editor.PositionCache -- Set number of entries in position cache

int editor.LayoutThreads -- Set maximum number of threads used for layout

editor:LinesSplit(int pixelWidth) -- Split the lines in the target into lines that are less wide than pixelWidth where possible.

editor:LinesJoin() -- Join the lines in the target.

line editor:WrapCount(line docLine) -- The number of display lines needed to wrap a document line

## Zooming

editor:ZoomIn() -- Magnify the displayed text by increasing the sizes by 1 point.

editor:ZoomOut() -- Make the displayed text smaller by decreasing the sizes by 1 point.

int editor.Zoom -- Set the zoom level. This number of points is added to the size of all fonts. It may be positive to magnify or negative to reduce.

## Long lines

int editor.EdgeMode -- The edge may be displayed by a line (EDGE_LINE/EDGE_MULTILINE) or by highlighting text that goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).

position editor.EdgeColumn -- Set the column number of the edge. If text goes past the edge then it is highlighted.

colour editor.EdgeColour -- Change the colour used in edge indication.

editor:MultiEdgeAddLine(position column, colour edgeColour) -- Add a new vertical edge to the view.

editor:MultiEdgeClearAll() -- Clear all vertical edges.

position editor.MultiEdgeColumn[int which] read-only

## Accessibility

int editor.Accessibility -- Enable or disable accessibility.

## Lexer

int editor.Lexer read-only

string editor.LexerLanguage read-only

pointer editor.ILexer write-only -- Set the lexer from an ILexer*.

editor:Colourise(position start, position end) -- Colourise a segment of the document using the current lexing language.

int editor:ChangeLexerState(position start, position end) -- Indicate that the internal state of a lexer has changed over a range and therefore there may be a need to redraw.

string editor:PropertyNames() -- Retrieve a '\n' separated list of properties understood by the current lexer. Result is NUL-terminated.

int editor:PropertyType(string name) -- Retrieve the type of a property.

string editor:DescribeProperty(string name) -- Describe a property. Result is NUL-terminated.

string editor.Property[string key] -- Set up a value that may be used by a lexer for some optional feature.

string editor.PropertyExpanded[string key] read-only

int editor:GetPropertyInt(string key, int defaultValue) -- Retrieve a "property" value previously set with SetProperty, interpreted as an int AFTER any "$()" variable replacement.

string editor.KeyWords[int keyWordSet] write-only -- Set up the key words used by the lexer.

string editor:DescribeKeyWordSets() -- Retrieve a '\n' separated list of descriptions of the keyword sets understood by the current lexer. Result is NUL-terminated.

string editor.SubStyleBases read-only

int editor.DistanceToSecondaryStyles read-only

int editor:AllocateSubStyles(int styleBase, int numberStyles) -- Allocate a set of sub styles for a particular base style, returning start of range

editor:FreeSubStyles() -- Free allocated sub styles

int editor.SubStylesStart[int styleBase] read-only

int editor.SubStylesLength[int styleBase] read-only

int editor.StyleFromSubStyle[int subStyle] read-only

int editor.PrimaryStyleFromStyle[int style] read-only

string editor.Identifiers[int style] write-only -- Set the identifiers that are shown in a particular style

pointer editor:PrivateLexerCall(int operation, pointer pointer) -- For private communication between an application and a known lexer.

int editor.NamedStyles read-only

string editor:NameOfStyle(int style) -- Retrieve the name of a style. Result is NUL-terminated.

string editor:TagsOfStyle(int style) -- Retrieve a ' ' separated list of style tags like "literal quoted string". Result is NUL-terminated.

string editor:DescriptionOfStyle(int style) -- Retrieve a description of a style. Result is NUL-terminated.

## Notifications

int editor.Identifier -- Set the identifier reported as idFrom in notification messages.

int editor.ModEventMask -- Set which document modification events are sent to the container.

bool editor.CommandEvents -- Set whether command events are sent to the container.

int editor.MouseDwellTime -- Sets the time the mouse must sit still to generate a mouse dwell event.