Page 1 of 3 123 LastLast
Results 1 to 40 of 114

Thread: Syntax Highlighting

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Syntax Highlighting

    I'm having a ***** of a time trying to impliment this. I know someone posted a project of thiers to do this, but there is ALOT of extra code in it, I'm not sure what everything does and while I know how to do some simple Regular Expressions, most within that project are very large with TONS of symbols in it, I don't know what they even do... lol. Also, I cannot get the same code to work AT ALL in a DLL file, which is what I'd need to incorporate it into.

    Basicly, my question is, what is the easyest way to impliment highlighting of certain keywords AND highlighting everything in between 2 characters a user would input.

    If someone has very simple examples, I should be able to work from there.

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Well... easy way? Don't think there is one...

    Without knowing much more about your requirements, I can only assume you mean highlighting code.

    In which case you have a Richtextbox in which you are examining the word a user has typed between two spaces... so you only need to examine the word once the user has pressed the space bar( or for html <>, +,-=,etc). Then you can run some code to determine if it is a keyword, if so, highlight the text.

    Same thing for parenthesis (), soon as the KeyPRess fires for one of those characters... examine whatever, do the same.
    Last edited by nemaroller; Aug 16th, 2003 at 10:40 AM.

  3. #3
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622
    can we see the code, maybe we can help you with it?
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  4. #4

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by <ABX
    can we see the code, maybe we can help you with it?
    I don't have it anymore and I forgot who made it. It's somewhere around here....

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Ask Edneeis . He's the one who posted a sample .

  6. #6
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Did you find it? I am needing some help as my code is slow as hell (it's in C# and right now is still just to select anyword and put it bold)
    Code:
    if (e.KeyCode == Keys.Space || e.KeyCode == Keys.Enter) {
    	int sStart = SelectionStart;
    	int pos = Text.LastIndexOf(" ", sStart);
    	if (pos != -1) {
    		this.SelectionStart = pos;
    		this.SelectionLength = sStart-pos;
    		this.SelectionFont = new Font("Verdana", 10, FontStyle.Bold);
    		this.SelectionStart = sStart;
    		this.SelectionLength = 0;
    	}
    }
    edit: now i saw some examples in pscode but they can suck my ass as they are very slow
    Last edited by PT Exorcist; Dec 26th, 2003 at 04:59 PM.
    \m/\m/

  7. #7

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by PT Exorcist
    Did you find it? I am needing some help as my code is slow as hell
    Never found it. At the time, I gave up and decided I hate VB.NET (I still do kindof). However, about 2 days ago I got bored and started working on the program again but I wasn't working on any of the syntax highlighting parts.

    So I still don't have any decent, fast and reliable code for syntax highlighting.

    I would still be interested in this if you found anything that can highlight a word easily.

  8. #8
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    I am searching about it www.codeproject.com
    \m/\m/

  9. #9
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    nothing!

    damn..should i look about it in the c++ files and try to port it to .net?
    \m/\m/

  10. #10
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

  11. #11
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    As far as i can see it only adds background highlighting capabilities to the RichTextBox.
    \m/\m/

  12. #12
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

  13. #13

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by PT Exorcist
    nothing!

    damn..should i look about it in the c++ files and try to port it to .net?
    I started porting my program to C++, but I decided not to because the code base is already in .NET and I got like 7,000 lines done. I really didn't feel like porting anything so that is pretty much why I started working in VB again, lol

    With richtextboxes, I know when it reads in something from like MS-Word, special escape characters mark words that are highlighted in different colors and such. So I would think searching the previous line the user' cursor was on and doing a replace with something like 'End' with 'End'.*




    * would be whatever escape cahracters the richtextbox would use for the color blue.

  14. #14
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    The code gives error everywhere and I didn't quite get how to work with it
    \m/\m/

  15. #15

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Pirate
    Another one ?
    http://www.planet-source-code.com/vb...=714&lngWId=10
    He wants it so if you're typing this into the richtextbox:

    Code:
    Hello, today is a wond
    When you're finished typing the selected word, it would automatically turn into this
    Code:
    Hello, today is a wonderful day.
    Those projects just highlight behind the words, but he wants to color or bold his words, not the background of them.

  16. #16
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Hey PT Exorcist , have you ever tried your code with
    Application.DoEvents method ?

  17. #17
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    hmm maybe what i'm doing is just not possible, the thing is I just realised that the file i am using has 29,800 lines

    damn it's going to be hard to do this with IL files
    \m/\m/

  18. #18
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by kasracer
    He wants it so if you're typing this into the richtextbox:

    Code:
    Hello, today is a wond
    When you're finished typing the selected word, it would automatically turn into this
    Code:
    Hello, today is a wonderful day.
    Those projects just highlight behind the words, but he wants to color or bold his words, not the background of them.
    lol , I know but I thought that might give him some clue . Since the code can change the background of a selected word , then it might be easier to just color it . lol

  19. #19

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by PT Exorcist
    hmm maybe what i'm doing is just not possible, the thing is I just realised that the file i am using has 29,800 lines

    damn it's going to be hard to do this with IL files
    No it is possible, Ednesis had a working syntax highlighter, I just never could impliment it for some reason. I don't remember why.... it was quite a while ago

  20. #20
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Originally posted by kasracer
    No it is possible, Ednesis had a working syntax highlighter, I just never could impliment it for some reason. I don't remember why.... it was quite a while ago
    Of course it is possible, but in the meantime maybe the speed is not acceptable, at least working in c#..
    \m/\m/

  21. #21

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by PT Exorcist
    Of course it is possible, but in the meantime maybe the speed is not acceptable, at least working in c#..
    Well if I ever finish my program, I'll let you know cause I'm sure there are ways to do it. I usually seem to figure out what I need to get done, lol.

    Wish I could have ported my VB.NET program to C#.NET, but it's like 7,000 lines and I really really don't feel like messing with it.

  22. #22
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    What about implementing something like this : http://www.icsharpcode.net/OpenSource/SD/Default.aspx

  23. #23
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Good idea, Two days ago i had that idea but i was unable to get to the net so i eventually forgot about it

    thanks
    \m/\m/

  24. #24
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by kasracer
    Well if I ever finish my program, I'll let you know cause I'm sure there are ways to do it. I usually seem to figure out what I need to get done, lol.

    Wish I could have ported my VB.NET program to C#.NET, but it's like 7,000 lines and I really really don't feel like messing with it.
    Well , if you wrote it in class files , then export it to dll and reference it in your C# proj and continue the proj in C# .

  25. #25

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Pirate
    Well , if you wrote it in class files , then export it to dll and reference it in your C# proj and continue the proj in C# .
    Nope, it's a program. Though I do have 1 DLL file so far, I'll probably port that one over to C# or maybe managed C++. The DLL doesn't have alot of source code right now.

  26. #26
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    but it's a .NET program? Just rename it to .DLL and you can reference it like any other .NET dll
    \m/\m/

  27. #27
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by PT Exorcist
    but it's a .NET program? Just rename it to .DLL and you can reference it like any other .NET dll
    You mean convert it to class library project instead of windows application project . Pretty easy and should work . I've tried this myself .

  28. #28

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by PT Exorcist
    but it's a .NET program? Just rename it to .DLL and you can reference it like any other .NET dll
    Not all of the code is in class files, though I could always try

  29. #29
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Originally posted by Pirate
    You mean convert it to class library project instead of windows application project . Pretty easy and should work . I've tried this myself .
    No, i mean an already created program EXE file can be used as a DLL as their only difference is that the EXE has a starting point
    \m/\m/

  30. #30
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by kasracer
    Not all of the code is in class files, though I could always try
    Even though , Forms , class files are actually classes in .NET . When you convert your windows application to class library application , you can still access forms and the class by instantiating them . Use are still able to show forms by Show() ...etc .

  31. #31
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by PT Exorcist
    No, i mean an already created program EXE file can be used as a DLL as their only difference is that the EXE has a starting point
    Are you referring to C# ? or stating the application written in VB.NET with Main method in module file ?

  32. #32
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    I mean creating your whole project as an EXE program. Then if later you still need the functions/classes and don't have the source you can just rename it to .DLL and use all it's functions/classes. You can even make this with comercial apps if they are not correctly protected with header obstruction
    \m/\m/

  33. #33
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I've just tried it and it's true . .
    Both ways work then .

  34. #34

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Ha that's cool.

    I think I'll just continue it in VB.NET, but I'll make ALL of my DLLs in C#. I do have a quick question though.

    Since we're already on this topic. in VB in my DLL projects, with my functions I make them public shared so I can use them in my main program.

    In C#, how would I do it? I already got about half my functions already ported to a C# DLL, I am just not sure how to declare the functions so I can use them in my program.

  35. #35
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by kasracer
    Ha that's cool.

    I think I'll just continue it in VB.NET, but I'll make ALL of my DLLs in C#. I do have a quick question though.

    Since we're already on this topic. in VB in my DLL projects, with my functions I make them public shared so I can use them in my main program.

    In C#, how would I do it? I already got about half my functions already ported to a C# DLL, I am just not sure how to declare the functions so I can use them in my program.
    Make them public in C# . You need to instantiate the class it resides in bfore usage . You can have them public static also so no need to have multiple instances of that class .

  36. #36

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Pirate
    Make them public in C# . You need to instantiate the class it resides in bfore usage . You can have them public static also so no need to have multiple instances of that class .
    Ahh so the classes work just like C++'s classes. In VB it doesn't seem to work that way, lol.

  37. #37
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by kasracer
    Ahh so the classes work just like C++'s classes. In VB it doesn't seem to work that way, lol.
    I don't know about C++ but MS says : VB.NET became fully OOP Language .

  38. #38

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Pirate
    I don't know about C++ but MS says : VB.NET became fully OOP Language .
    In VB, within my DLL I can create classes and use them without actually instantiating the class.

    C++'s classes work like C#s for the most part is seems (I don't really know anything of C#, lol)

  39. #39

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Pirate
    You need to instantiate the class it resides in bfore usage .
    How do you do this? I can't seem to access the namespace they are within....

  40. #40
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Originally posted by kasracer
    How do you do this? I can't seem to access the namespace they are within....
    How to instanciate what? If the class is not static instead of doing

    Code:
    MyClass.MyMethod();
    you do just like in c++(note that unlike c++ there is no shortway of constructors)
    Code:
    MyClass myClass = new MyClass();
    myClass.MyMethod();
    Now i am seeing the code of #develop and as IDE it might suck but generally it's a damn good program as you can see everything they've done. I'm goin try to learn how they made all that GUI part as it is very clean and cool..


    Anyways right now I think i'll just do all the coloring thing when I load the file and from them on it just re-colors it like from 2 to 2 mins or something like that..

    The purpose of the program isn't actually to create base IL files but to edit them *argh*
    Edit: Am I allowed to use #develop classes if i mention that in my program? anyways if I ever finish it I wont sell it
    Last edited by PT Exorcist; Dec 26th, 2003 at 07:20 PM.
    \m/\m/

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width