|
-
Aug 14th, 2003, 06:26 PM
#1
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.
-
Aug 16th, 2003, 10:35 AM
#2
I wonder how many charact
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.
-
Aug 16th, 2003, 12:14 PM
#3
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
-
Aug 16th, 2003, 12:37 PM
#4
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....
-
Aug 17th, 2003, 01:17 PM
#5
Sleep mode
Ask Edneeis . He's the one who posted a sample .
-
Dec 26th, 2003, 04:55 PM
#6
yay gay
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/
-
Dec 26th, 2003, 05:04 PM
#7
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.
-
Dec 26th, 2003, 05:06 PM
#8
yay gay
I am searching about it www.codeproject.com
\m/  \m/
-
Dec 26th, 2003, 05:10 PM
#9
yay gay
nothing!
damn..should i look about it in the c++ files and try to port it to .net?
\m/  \m/
-
Dec 26th, 2003, 05:12 PM
#10
Sleep mode
-
Dec 26th, 2003, 05:13 PM
#11
yay gay
As far as i can see it only adds background highlighting capabilities to the RichTextBox.
\m/  \m/
-
Dec 26th, 2003, 05:15 PM
#12
Sleep mode
-
Dec 26th, 2003, 05:17 PM
#13
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.
-
Dec 26th, 2003, 05:18 PM
#14
yay gay
The code gives error everywhere and I didn't quite get how to work with it
\m/  \m/
-
Dec 26th, 2003, 05:19 PM
#15
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.
-
Dec 26th, 2003, 05:21 PM
#16
Sleep mode
Hey PT Exorcist , have you ever tried your code with
Application.DoEvents method ?
-
Dec 26th, 2003, 05:24 PM
#17
yay gay
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/
-
Dec 26th, 2003, 05:24 PM
#18
Sleep mode
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
-
Dec 26th, 2003, 05:26 PM
#19
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
-
Dec 26th, 2003, 05:27 PM
#20
yay gay
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/
-
Dec 26th, 2003, 05:32 PM
#21
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.
-
Dec 26th, 2003, 05:33 PM
#22
Sleep mode
-
Dec 26th, 2003, 05:34 PM
#23
yay gay
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/
-
Dec 26th, 2003, 05:35 PM
#24
Sleep mode
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# .
-
Dec 26th, 2003, 05:39 PM
#25
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.
-
Dec 26th, 2003, 05:43 PM
#26
yay gay
but it's a .NET program? Just rename it to .DLL and you can reference it like any other .NET dll
\m/  \m/
-
Dec 26th, 2003, 05:46 PM
#27
Sleep mode
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 .
-
Dec 26th, 2003, 05:47 PM
#28
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
-
Dec 26th, 2003, 05:50 PM
#29
yay gay
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/
-
Dec 26th, 2003, 05:50 PM
#30
Sleep mode
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 .
-
Dec 26th, 2003, 05:52 PM
#31
Sleep mode
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 ?
-
Dec 26th, 2003, 05:54 PM
#32
yay gay
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/
-
Dec 26th, 2003, 06:00 PM
#33
Sleep mode
-
Dec 26th, 2003, 06:11 PM
#34
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.
-
Dec 26th, 2003, 06:29 PM
#35
Sleep mode
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 .
-
Dec 26th, 2003, 06:30 PM
#36
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.
-
Dec 26th, 2003, 06:34 PM
#37
Sleep mode
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 .
-
Dec 26th, 2003, 06:37 PM
#38
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)
-
Dec 26th, 2003, 06:57 PM
#39
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....
-
Dec 26th, 2003, 07:09 PM
#40
yay gay
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/
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
|