Auto-indenting in ScintillaControlMBS?

Can the Scintilla control be configured to do auto-indenting, like the Xojo IDE editor does with Xojo code? I’m so used to it now that doing manual indenting is a royal pain in the nether region.

it does indent automatically.

At least it looks for me like it does. Or do I miss something?

Well I don’t see it.

If I type the following lines with no leading spaces or tabs in the Xojo example:

function NoIndentingVisible() as Fruitbat
return new Fruitbat
end function

I expect the second line to be indented automagically. Not so.

A shot in the dark, could it be because on line 3 you wrote

function NoIdentingVisible() as Fruitbat

instead of

Function NoIdentingVisible() As Fruitbat

function → Function
return → Return


Nope. But good suggestion.

Sorry, I think it does not do Auto indent.
But we may check to add this for an example.

So I will add this to the example project:

// new line
If Character = 13 Or Character = 10 Then 
  Dim CurrentPosition As Integer = Me.Position
  Dim curLine As Integer = Me.LineFromPosition(CurrentPosition)
  Dim lineLength As Integer = Me.LineLength(curLine)
  If curLine > 0 And lineLength < 2 Then
    // beginning on a new line
    Dim prevLine As String = Me.Line(curLine-1)
    Dim Len As Integer = 0
    For i As Integer = 1 To prevLine.Len
      Dim ch As String = prevLine.Mid(i, 1)
      If Asc(ch) = 9 Or Asc(ch) = 32 Then
        // we take that
        Len = i
        // start of text, so exit
      End If
    Dim prefix As String = prevLine.Left(Len)
  End If
End If

goes into CharacterAdded event on top and should do a little bit there.

Sadly it does not seem to make any difference.

Correction: Yes, it keeps the indentation that same as the previous line. However it doesn’t recognise that after, say, while, for, if, etc. it should be indented a further 4 spaces, or that wend, next, else, etc. should be outdented.

So, thanks for that: it’s waaaay better than no indenting at all…

Yes, this could be extended, e.g. after you press return on the “next” line, it could detect that and reduce level.