« Search relationship g… | Home | Regular Expressions i… »

More Scintilla questions

Scintilla is very powerful, but finding something in the documentation can be troublesome. let's summary a few questions from you guys around ScintillaControlMBS control:

How to show whitespace?

Please check ViewWS property and use the constants:

  • kWhiteSpaceVisibleOnlyInIndent
  • kWhiteSpaceVisibleAlways
  • kWhiteSpaceVisibleAfterIndent
  • kWhiteSpaceInvisible

e.g.

c.ViewWS = c.kWhiteSpaceVisibleAlways

Can I overwrite whitespace colors?

You can use SetWhitespaceForeColor and SetWhitespaceBackColor methods to overwrite what the lexer sets.

How to show End Of Line characters?

Please check EOLAnnotationVisible property and set it to one of the modes:

  • kEOLAnnotationVisibleStandard
  • kEOLAnnotationVisibleStadium
  • kEOLAnnotationVisibleHidden
  • kEOLAnnotationVisibleFlats
  • kEOLAnnotationVisibleFlatCircle
  • kEOLAnnotationVisibleFlatAngle
  • kEOLAnnotationVisibleCircleFlat
  • kEOLAnnotationVisibleCircleAngle
  • kEOLAnnotationVisibleBoxed
  • kEOLAnnotationVisibleAngles
  • kEOLAnnotationVisibleAngleFlat
  • kEOLAnnotationVisibleAngleCircle

How to remove a key mapping with Scintilla?

If you don't like a remove a default binding for a key, you can use ClearCmdKey method like this:

c.ClearCmdKey(KeyCode + Bitwise.ShiftLeft(c.kKeyModCtrl, 16))

You combine the key code with the shifted bits for the modified keys. Above we use control, but you can just OR them together, if you need multiple.

How to change the color of the cursor for text inserts?

Well, the cursor where you enter text is named cared in Scintilla. Please check the CaretForeColor property for the color of the caret. Also check CareWidth for the width and CaretPeriod for the duration for blinking.

e.g.

Dim ScintillaEditor As ScintillaControlMBS // your control // set cursor width and color ScintillaEditor.CaretForeColor = Color.HighlightColor ScintillaEditor.CaretWidth = 8

How to color the area for code folding?

This is a chequerboard, where two colors make the final coloring:

// Set one Of the colours used As a chequerboard pattern In the fold margin editor.SetFoldMarginColor(True, &c00FF00) // Set the other colour used As a chequerboard pattern In the fold margin editor.SetFoldMarginHighlightColor(True, &c0000FF)

The FoldMarginColor and the FoldMarginHighlightColor colors are used together to draw the chequerboard pattern in the folder margin.

Which colors are considered as text and which as whitespace?

See WordCharacters and WhitespaceChars properties, which define what characters are considered words and what is whitespace. Default Whitespace includes space, return and tab characters.

How to control wrap mode?

See WrapMode property and the constants related to it.

  • kWrapNone
  • kWrapChar
  • kWrapWhiteSpace
  • kWrapWord

Where may I find what styles to set for a lever?

You can lookup the source code of the open source Scite application to get inspired. Since Scite uses Scintilla as editor, you can easily translate their definitions to Xojo code:

github.com/LuaDist/scite/tree/master/src

e.g. for CSS you look on the properties for it:

github.com/LuaDist/scite/blob/master/src/css.properties

Translation may go like this:

A line with "keywords3.*.css" setting it to a list of keywords may translate to an assignment to KeyWords(index) property.
Style definitons translate to the properties, e.g.

style.css.11=fore:#FF8000,bold

Leads to:

c.Style(11).ForeColor = &FF8000 c.Style(11).bold = True

But if you look into the LexerConstants.txt file we include with the plugin, you can see that there are constants for CSS and you can replace 11 with SCE_CSS_IMPORTANT constant.

Const SCE_CSS_IMPORTANT = 11 c.Style(SCE_CSS_IMPORTANT).ForeColor = &FF8000 c.Style(SCE_CSS_IMPORTANT).bold = True

See also older articles

18 03 23 - 10:35