Does anyone know how to change the font size, i’ve tried all examples I’ve found on the net and still have not been able to do it.
Quite a while ago, when I was still using xojo, I also used the Scintilla editor.
Here’s an example of configuring the editor from one of my projects.
Put the following in the Opening event of the Scintilla control (API 2)
Self.ScintillaSetup(Me)
Which calls this method:
Private Sub ScintillaSetup(c As DesktopScintillaControlMBS)
c.InitializeLexer("xojo")
Var dark As Boolean = Color.IsDarkMode
Const SCE_XOJO_DEFAULT As Integer = 0
Const SCE_XOJO_COMMENT As Integer = 1 // // or ' or starts with "REM "
Const SCE_XOJO_NUMBER As Integer = 2 // &h, &b, &o or other literals
Const SCE_XOJO_COLOR As Integer = 3 // starts &c
Const SCE_XOJO_UNICODE As Integer = 4 // starts &u
Const SCE_XOJO_STRING As Integer = 5 // starts with "....."
Const SCE_XOJO_OPERATOR As Integer = 6
Const SCE_XOJO_PREPROCESSOR As Integer = 7 // #if #pragma
Const SCE_XOJO_KEYWORD As Integer = 8
Const SCE_XOJO_BOOLEAN As Integer = 9 // ie TRUE / FALSE
Const SCE_XOJO_IDENTIFIER As Integer = 10
Const SCE_XOJO_COLOR_RED As Integer = 11 // starts &c default color is RED
Const SCE_XOJO_COLOR_GREEN As Integer = 12 // starts &c default color is GREEN
Const SCE_XOJO_COLOR_BLUE As Integer = 13 // starts &c default color is BLUE
Const SCE_XOJO_COLOR_ALPHA As Integer = 14 // starts &c default color is the system default text color based on light mode dark mode
Const SCE_XOJO_INTEGER As Integer = 15
Const SCE_XOJO_FLOATING As Integer = 16
// Var factor As Double = 1
Var reservedWords As String = "addhandler addressof aggregates and array as assigns async " _
+ "attributes await break byref byval call case catch class const continue ctype declare " _
+ "delegate dim do downto each else elseif end enum event exception exit extends false " _
+ "finally for function global goto handles if implements in inherits interface is isa " _
+ "lib loop me mod module namespace new next nil not object of optional or paramarray " _
+ "private property protected public raise raiseevent redim rem removehandler return " _
+ "select self shared soft static step structure sub super then to true try until using " _
+ "var weakaddressof wend while with xor"
Var dataTypes As String = "auto boolean cfstringref cgfloat color cstring currency double " _
+ "int8 int16 int32 int64 integer object ostype pstring ptr short single string text " _
+ "uint8 uint16 uint32 uint64 uinteger variant windowptr wstring"
Var functionKeyWords As String = "private protected public sub function handles extends assigns"
Var pragmaKeyWords As String = "#pragma #if #elseif #endif"
// following custom function not used in this case
// AddWordsForAutoComplete(reservedWords)
// AddWordsForAutoComplete(dataTypes)
// Keywords to highlight. Indices are:
// 0 - Major keywords (reserved keywords)
// 1 - Normal keywords (everything not reserved but integral part of the language)
// 2 - Database objects
// 3 - Function keywords
// 4 - System variable keywords
// 5 - Procedure keywords (keywords used in procedures like "begin" and "end")
// 6..8 - User keywords 1..3
c.KeyWords(0) = reservedWords
c.KeyWords(1) = dataTypes
c.KeyWords(3) = functionKeyWords
c.KeyWords(7) = pragmaKeyWords
// default font
// Colors and styles for various syntactic elements. First the default style.
c.Style(ScintillaStyleMBS.kStylesCommonDefault).Font = "Menlo"
c.Style(ScintillaStyleMBS.kStylesCommonDefault).Size = 14
c.Style(ScintillaStyleMBS.kStylesCommonDefault).ForeColor = If(dark, &cFFFFFF00, &c00000000)
c.Style(ScintillaStyleMBS.kStylesCommonDefault).BackColor = If(dark, Color.black, Color.white)
c.StyleClearAll()
// Xojo style codes
c.Style(SCE_XOJO_DEFAULT).ForeColor = If(dark, &cFFFFFF00, &c00000000)
c.Style(SCE_XOJO_COMMENT).ForeColor = &c107F0100
c.Style(SCE_XOJO_NUMBER).ForeColor = &cFB010600 // &c5856D600
c.Style(SCE_XOJO_COLOR).ForeColor = &c00000000
c.Style(SCE_XOJO_UNICODE).ForeColor = &c3A37A500
c.Style(SCE_XOJO_STRING).ForeColor = &c80000200
c.Style(SCE_XOJO_STRING).Bold = True
c.Style(SCE_XOJO_OPERATOR).ForeColor = If(dark, &cCCCCCC00, &c33333300)
c.Style(SCE_XOJO_OPERATOR).Bold = True
c.Style(SCE_XOJO_PREPROCESSOR).ForeColor = &c595BB400
c.Style(SCE_XOJO_KEYWORD).ForeColor = &c0432FF00
c.Style(SCE_XOJO_KEYWORD).Bold = True
c.Style(SCE_XOJO_BOOLEAN).ForeColor = &c0432FF00
c.Style(SCE_XOJO_IDENTIFIER).ForeColor = If(dark, &cFFFFFF00, &c00000000)
c.Style(SCE_XOJO_COLOR_RED).ForeColor = &cFF000000
c.Style(SCE_XOJO_COLOR_GREEN).ForeColor = &c00FF0000
c.Style(SCE_XOJO_COLOR_BLUE).ForeColor = &c0000FF00
c.Style(SCE_XOJO_COLOR_ALPHA).ForeColor = If(dark, &cFFFFFF00, &c00000000)
c.Style(SCE_XOJO_INTEGER).ForeColor = &cFB010600
c.Style(SCE_XOJO_FLOATING).ForeColor = &cFB010600
// Line number style.
c.Style(ScintillaStyleMBS.kStylesCommonLineNumber).ForeColor = &c828282
c.Style(ScintillaStyleMBS.kStylesCommonLineNumber).BackColor = If(dark, &c2B2B2B00, &cE0E0E000)
c.Margin(0).Type = ScintillaMarginMBS.kMarginTypeNumber
c.Margin(0).Width = 38 // * factor // wide enough for 4 digits (9999)
// Marker for bookmark
// using this to create a coloured vertical line between
// the line numbers and code text
c.Margin(1).Type = ScintillaMarginMBS.kMarginTypeColour
c.Margin(1).Width = 1 // * factor
c.Margin(1).Mask = 1
c.Margin(1).BackColor = If(dark, &c65656500, k.Color.gray)
// c.Margin(1).Sensitive = False // allow click
// Some special lexer properties.
c.PropertyValue("fold") = "0"
// Folder setup.
c.Margin(2).Width = 0 // * factor
// uncomment if you wanna see auto wrapping in action.
// c.WrapIndentMode = c.kWrapIndentModeIndent
// c.WrapMode = c.kWrapWord
// Set the caret color to red
c.CaretForeColor = if(dark, &cFFFFFF00, &c00000000)
// Enable and set the caret line background color to slightly transparent blue
c.CaretLineVisible = True
c.CaretLineBackColor = If(dark, &c2C2C2C50, Color.gray)
// Set the caret width of 4 pixels
c.CaretWidth = 2
c.ShowInfoBar = False // see control Inspector Properties
End Sub
Hope that helps to get you started.
No luck, font still tiny.
’ Set font + font size ONLY (no other styling)
ScintillaControl.InitializeLexer(“xojo”)
Const FONT_NAME As String = “Menlo”
Const FONT_SIZE As Integer = 64
’ 1) Set the default style FIRST
ScintillaControl.Style(ScintillaStyleMBS.kStylesCommonDefault).Font = FONT_NAME
ScintillaControl.Style(ScintillaStyleMBS.kStylesCommonDefault).Size = FONT_SIZE
’ 2) Copy default style to ALL styles (this is the key step)
ScintillaControl.StyleClearAll()
’ 3) (Optional but usually desired) make line numbers match too
ScintillaControl.Style(ScintillaStyleMBS.kStylesCommonLineNumber).Font = FONT_NAME
ScintillaControl.Style(ScintillaStyleMBS.kStylesCommonLineNumber).Size = FONT_SIZE
Even a stripped down version does not seem to work.
Solved, missed desktop in front of the object name!! , caused all kinds of issues.
Thanks for your help
Oh blech !
He adopted that silly naming convention too ?
Arg !
All MBS Controls exist in two variants: with or without Desktop.
You can use the right one for your projects as needed.
See the list here:
Maybe the problem with ScintillaControl.Style is that you missed MBS at the end and should be: ScintillaControlMBS.Style, no?
And you changed to DesktopScintillaControlMBS.Style, and that worked, right?
Are they based on different supers ?
if not that naming convention Xojo adopted is just awful
Now NOTHING completes decently until you type “Desktop”, or web or mobile etc first
I suspect I know WHY they did this but its awful
Yes, ScintillaControlMBS is a RectControl while DesktopScintillaControlMB is a DesktopUIControl.
We register two controls and they use the same code, same methods/properties. Just the events are adjusted with some renames, e.g. EnableMenuItems → MenuBarSelected.
That all happens automatically for 30 controls, so no big problem for me. More like having two flavors in code.
Yeah Internally I get how you could set that up its just I truly despise those prefixes as they make autocomplete even more useless - more more useful