|
-
Oct 1st, 2000, 05:12 PM
#1
Thread Starter
New Member
I'm building a simple java editor and would like to add a functionality such
as following:
I would like my editor to recognize keywords such as "class", "if",
"switch", "case", "return", etc... Upon recognition, I want the editor to
make those keywords bold face. If I it is possible, I would like the editor to
perform the above action on opening any saved *.java files and also as I type them.
Something similar to VB code editor. Does any one have source code or idea on how to do this ?
Many thanks in advance.
-
Oct 1st, 2000, 06:08 PM
#2
Hi,
Check this thread i think this is what you are looking for.
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Oct 1st, 2000, 06:11 PM
#3
Add the following to a Form with a RichTextBox.
Code:
Private Sub HighlightText(sKeyword As String, iColour As Long)
Dim nStart As Integer, sPrevChar As String, sNextChar As String
nStart = InStr(1, LCase(RichTextBox1.Text), sKeyword)
Do While nStart <> 0
If nStart > 1 Then
sPrevChar = Mid$(RichTextBox1.Text, nStart - 1, 1)
Else
sPrevChar = " "
End If
If Len(RichTextBox1.Text) >= nStart + Len(sKeyword) Then
sNextChar = Mid$(RichTextBox1.Text, nStart + Len(sKeyword), 1)
Else
sNextChar = " "
End If
If (sPrevChar = Chr(32) Or sPrevChar = Chr(13) Or _
sPrevChar = Chr(10) Or sPrevChar = Chr(9)) And _
(sNextChar = Chr(32) Or sNextChar = Chr(13) Or _
sNextChar = Chr(10) Or sNextChar = Chr(9)) Then
With RichTextBox1
.SelStart = nStart - 1
.SelLength = Len(sKeyword)
.SelColor = iColour
.SelBold = True
.SelStart = Len(RichTextBox1.Text)
.SelColor = iColour
.SelBold = False
End With
End If
nStart = InStr(nStart + Len(sKeyword), LCase(RichTextBox1.Text), sKeyword)
Loop
End Sub
Private Sub Form_Resize()
RichTextBox1.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
Private Sub RichTextBox1_Change()
With RichTextBox1
.SelStart = 0
.SelLength = Len(.Text)
.SelColor = vbBlack
.SelStart = Len(.Text)
End With
' Add more custom words here
HighlightText "if", vbBlack
HighlightText "class", vbBlack
HighlightText "switch", vbBlack
HighlightText "if", vbBlack
End Sub
-
Oct 2nd, 2000, 08:43 PM
#4
Thread Starter
New Member
Thanks a lot for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|