login about faq

Due to the large amount of spam accounts, we temporarily disabled new user sign ups. To override this, email newuser.lgqa@gmail.com and an admin will determine if you are permitted to join


At the moment I'm working on a simple syntax highlighter and I have couple of problems. Could you help me out?

I have a class library with a component class in it. Everything is in VB.NET. It's only one file so you can see it here https://gist.github.com/2366507 . On line 92, there is the OnTextChanged Sub. I was thinking about adding ProcessAllLines() (as on line 128) to the end of that Sub, and it worked. However when I was typing in code to the RichTextBox (source which I used is here https://gist.github.com/2366526) after each text change it was checking and processing ALL the lines. So I deleted ProcessAllLines() in the OnTextChanged Sub.

I'm thinking about running ProcessAllLines() when the user pastes something to the SyntaksRichTextBox. However I do not know how to do that. I know that it should be something like:

If [CTRL Pressed] And [V Pressed] Then
ProcessAllLines()
End If

I also want it to be in the class library, not the application (Syntaks Demo). Could you help me out here? Thanks.

Rafal Chmiel, @RafalChmiel

asked Apr 12 '12 at 07:15

RafalChmiel's gravatar image

RafalChmiel
491138151156


for this type of thing an if statement is not going to work, if i understand the problem...

What you need is an event, try this:

Private Sub Paste_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
  If e.Control And e.KeyValue = Keys.V Then
       MsgBox("It worked")
  End If 
End Sub

An if statement will execute subsequently, this will work as an interrupt.

answered Apr 12 '12 at 14:08

trueb's gravatar image

trueb
15.0k4999256

edited Apr 15 '12 at 09:44

Doesn't seem to work.

(Apr 12 '12 at 15:16) RafalChmiel RafalChmiel's gravatar image

How can I add this to the class library (https://gist.github.com/2366507) not the Demo (Windows Forms https://gist.github.com/2366526)

(Apr 12 '12 at 15:17) RafalChmiel RafalChmiel's gravatar image

Sorry, it actually works.

(Apr 14 '12 at 10:49) RafalChmiel RafalChmiel's gravatar image

Can I be a real pain and point out that there are several ways to paste text that do not require the keyboard at all and therefore you need another solution anyway? It seems to me that if you're using a single textbox as both input and display there really isn't any choice but to process all lines continually. What you need is some way of separating the lines so that colouring takes place only at the completion of each line and only for that line and a textbox is not designed with that purpose in mind.

answered Apr 13 '12 at 12:24

Cornelia%20Cornflake's gravatar image

Cornelia Cornflake
8802316

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported


Join Us in the Chat Room

Tags:

×28
×22
×4
×1

Asked: Apr 12 '12 at 07:15

Seen: 512 times

Last updated: Apr 15 '12 at 09:44