Login Register






Help with Perl Text editor Im making filter_list
Author
Message
Help with Perl Text editor Im making #1
basically iv been looking for a perl IDE that was free and did what i want. Couldnt find so i decided to try and make one, the problem that im having is, with:
- Syntax Highlighting
- Run in CMD

Basically it's been a long time since i did any VB.NET coding and so if anyone can help me with this would be a big help.
[Image: 6caf54.gif]

Reply

RE: Help with Perl Text editor Im making #2
Willing to help, no prob.. but you have to clarify a bit..
- Syntax Highlighting: looks clear to me but what do you got so far?
- Run in CMD: what exactly do you want to run in CMD? the .net program?

Reply

RE: Help with Perl Text editor Im making #3
no, alot of perl programs are command line and so i want it to run the following command in the cmd - filename.pl

and im not really anywhere with the syntax highlighting, i heard about regex but i dont know where to go - haven't coded in VB in ages
[Image: 6caf54.gif]

Reply

RE: Help with Perl Text editor Im making #4
syntax highlighting:

assuming you have a RichTextBox (RichTextBox1) and a button (Button1)

Code:
Private dictionary As Dictionary(Of [String], [String]) = returnDictionary() Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.doSearch() End Sub Public Sub doSearch() Dim regex__1 = "\b(?:" & [String].Join("|", dictionary.Keys.ToArray()) & ")\b" Me.SearchRichTextBox(regex__1, Color.Blue, False) End Sub Private Function returnDictionary() As Dictionary(Of String, String) 'fill your dictionary with the syntaxis you want to be found... 'the values are not really used is this example, only the keys.. but you can implement them as well in the regex to replace some short keywords for example with full code.. 'this however is beyond this little tut, just showing how to find and highlight certain words.. Dim dict As New Dictionary(Of String, String) dict.Add("test", "good") dict.Add("is", "was") Return dict End Function Private Sub SearchRichTextBox(ByVal Pattern As String, ByVal HighlightColor As Color, Optional ByVal RemovePreviousHighlight As Boolean = True) 'Make sure we are ready to continue. If String.IsNullOrEmpty(Pattern) Then Exit Sub 'no pattern text for text seach If Me.RichTextBox1.TextLength = 0 Then Exit Sub 'no text to be searched 'If no color is passed then assign a default color of Yellow. If HighlightColor = Color.Empty Then HighlightColor = Color.Yellow 'Get the position of the cursors Dim initialSelection As Integer = Me.RichTextBox1.SelectionStart 'Un-Highlight all text if RemovePreviousHighlight is true If RemovePreviousHighlight Then Me.RichTextBox1.SelectAll() Me.RichTextBox1.SelectionBackColor = Me.RichTextBox1.BackColor End If 'Get an instance of the Regex class using our Pattern. Dim regex As New System.Text.RegularExpressions.Regex(Pattern) 'Loop through each match, select it, and then highlight it. For Each match As System.Text.RegularExpressions.Match In regex.Matches(Me.RichTextBox1.Text) With Me.RichTextBox1 .Select(match.Index, match.Length) .SelectionColor = HighlightColor '.SelectionBackColor = HighlightColor 'other option: set backgroundcolor instead of font color... End With Next 'Set the selection back to the beginning Me.RichTextBox1.Select(initialSelection, 0) End Sub

For the CMD part...
see this thread: http://www.hackcommunity.com/Thread-how-...pplication

Reply

RE: Help with Perl Text editor Im making #5
Thanks very much for the help, is there a way to make the highlighting live so the colour changes when you finnish the word etc, like on notepad++
[Image: 6caf54.gif]

Reply

RE: Help with Perl Text editor Im making #6
sure, just implement the RichTextBox1.TextChanged handler.
When doing, perhaps write another routine so you don't have to check the entire richtextbox again, but just the last word / x characters...

little example: (can / must be improved)

Code:
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged 'get current cursor position Dim initialSelection As Integer = Me.RichTextBox1.SelectionStart 'go back and forward until a space is reached Dim foundChar As Char Dim currentPos As Integer = initialSelection Do Until (foundChar = " ") OrElse currentPos = 0 foundChar = Me.RichTextBox1.Text(currentPos - 1) If Not foundChar = " " Then currentPos -= 1 End If Loop Dim fndWord As String = Me.RichTextBox1.Text.Substring(currentPos, (initialSelection - currentPos)) Dim regex__1 = "\b(?:" & [String].Join("|", dictionary.Keys.ToArray()) & ")\b" Dim regex As New System.Text.RegularExpressions.Regex(regex__1) 'Loop through each match, select it, and then highlight it. For Each match As System.Text.RegularExpressions.Match In regex.Matches(fndWord) With Me.RichTextBox1 'MessageBox.Show("match length = " & match.Length) .Select(currentPos, match.Length) .SelectionColor = Color.Blue '.SelectionBackColor = HighlightColor End With Next Me.RichTextBox1.Select(initialSelection, 0) RichTextBox1.SelectionColor = Color.Black End Sub

Reply