Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim Starters() As String = {"if", "while", "for", "with"}
- Dim Enders() As String = {"end if", "end while", "next", "end with"}
- Dim CapsEnders() As String = {"End If", "End While", "Next", "End With"}
- If Not e.Ch = ChrW(Keys.Return) Then Exit Sub
- Dim P As String = MainTextBox.Lines(MainTextBox.Caret.LineNumber - 1).Text
- P = P.Substring(0, P.Length - 2)
- If P.Length = 0 Then Exit Sub
- Dim SpaceCount As SByte = 0
- For i As Byte = 0 To P.Length - 1
- If Not P.Substring(i).StartsWith(" ") Then Exit For
- SpaceCount += 1
- Next
- Dim F As String = P.Substring(SpaceCount).ToLower
- Dim Amount As Byte = 1
- If SpaceCount Mod 2 = 0 Then Amount = 2
- Dim FID As Byte = 100
- For DOn As Byte = 0 To Starters.Count - 1
- If F.StartsWith(Starters(DOn) + " ") Then FID = DOn : Exit For
- Next
- If Not FID = 100 Then
- MainTextBox.InsertText(MakeSpaces(SpaceCount + Amount))
- Dim DoAdd As Boolean = True
- For i As Byte = MainTextBox.Caret.LineNumber To MainTextBox.Lines.Count - 1
- Dim L As String = MainTextBox.Lines(i).Text
- L = L.Substring(0, L.Length - 2).ToLower
- If L.Length = 0 Or L.Length <= SpaceCount Then Continue For
- L = L.Substring(SpaceCount)
- If L = Enders(FID).ToLower Then DoAdd = False
- Next
- If DoAdd Then
- Dim BackupPos As Int16 = MainTextBox.Caret.Position
- MainTextBox.InsertText(Environment.NewLine + MakeSpaces(SpaceCount) + CapsEnders(FID))
- MainTextBox.Caret.Position = BackupPos
- MainTextBox.Selection.Length = 0
- End If
- Exit Sub
- End If
- Dim IsOne As Boolean = False
- For Each D As String In Enders
- If F = D Then IsOne = True
- Next
- If F.StartsWith("next ") Then IsOne = True
- If IsOne And SpaceCount = TempSpaces Then
- SpaceCount -= Amount
- Dim FX As String = P
- If FX.StartsWith(MakeSpaces(Amount)) Then
- FX = FX.Substring(Amount)
- MainTextBox.Lines(MainTextBox.Caret.LineNumber - 1).Text = FX
- End If
- End If
- If SpaceCount < 0 Then SpaceCount = 0
- TempSpaces = SpaceCount
- MainTextBox.InsertText(MakeSpaces(SpaceCount))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement