 |
|
|
I really need this one. fortunately I found in my first search from google.
Again, Thanks a lot for sharing.
dnpro "Very bad programmer"
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
The do-whatever-you-want-licence.
"If knowledge can create problems, it is not through ignorance that we can solve them." Isaac Asimov
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
Is there any way to background highlight a line if it STARTS WITH "fox", then highlight the entire line AS THE USER IS TYPING ?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Thank you for the control; it's great. I gave you a 5.
BTW, I used your control in my application and I gave you credit at the bottom of the article. You can check out the article here: http://www.codeproject.com/KB/recipes/EvaluationEngine.aspx
Donald.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
Hi,
To solve Redo/Undo problem:
Use TextEditorControl_KeyUp event instead of TextEditorControl_TextChanged or TextEditorControl_KeyPress events.
Now, Redo/Undo works.
To bypass Redo/Undo selection steps, REWRITE a NEW Undo/Redo and DO base.Undo/base.Redo until Text property changes.
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
|
I do not really think that you need to rewrite the REDO or UNDO.
// <summary> /// OnTextChanged /// </summary> /// <param name="e"></param> protected override void OnKeyUp(KeyEventArgs e) { if (!e.Control) { m_nContentLength = this.TextLength;
int nCurrentSelectionStart = SelectionStart; int nCurrentSelectionLength = SelectionLength;
m_bPaint = false;
// Find the start of the current line. m_nLineStart = nCurrentSelectionStart; while ((m_nLineStart > 0) && (Text[m_nLineStart - 1] != '\n')) m_nLineStart--; // Find the end of the current line. m_nLineEnd = nCurrentSelectionStart; while ((m_nLineEnd < Text.Length) && (Text[m_nLineEnd] != '\n')) m_nLineEnd++; // Calculate the length of the line. m_nLineLength = m_nLineEnd - m_nLineStart; // Get the current line. m_strLine = Text.Substring(m_nLineStart, m_nLineLength);
// Process this line. ProcessLine();
m_bPaint = true; } else if (e.KeyCode == Keys.Z) { base.OnKeyUp(e); } }
should be solving the problem, this is just a quick answer, you might find better idea to solve the problem
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
What if you are using html as syntax... i tried "<html>" & "<html" both... i think "<" is not working..
I was using this RTF Box in a small html editor and taking preview on a WebBrowser, i tried to used TextChanged Event, the Event is not working the Break point on this point doesnt get a hit on text changed.
is it right?
ASif Ashraf MCAD.Net,MCP Asif.Log@gmail | hotmail.com 92-306-4526526 Sr. dotNet & Flash Developer Blu Media Works LHR PK
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Probably not.
"If knowledge can create problems, it is not through ignorance that we can solve them." Isaac Asimov
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
hmmm.. thats fine.. no problem ....
anyhow i checked and it dint work fine with me.. maybe my own fault... i just added keywords and did nothing else....
bye
-- ASif Ashraf MCAD.Net,MCP Asif.Log@gmail | hotmail.com 92-306-4526526 Sr. dotNet & Flash Developer Blu Media Works LHR PK
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I am using this code as the base of my syntax highlighter and there are several things that i've done to reduce loading time. Here is something you can do: 1. Process line when user hits space bar, rather than having it processed as a new char gets added. 2. Preload regular expressions. I have a DLL with all of my regular expressions in it. The dll is loaded once on start-up and then used throughout the code so that you don't create a new regex instance while abandoning the previous one. 3. Use standard RichTextBox operations to perform line calculations instead of doing everything in loops. 4. When processing a line, split it by empty space and use a for each loop to traverse through a line looking for keywords. This is more efficient than using for loops. I also used a balanced binary tree to store keywords which have already been highlighted and the position of their last character. This way, if i have a duplication keyword on one line i can keep track of them. All of this reduced loading time significantly. You could also put some operations in threads if you wanted an even better performance.
|
| Sign In·View Thread·PermaLink | 4.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
To implement Space bar and return processing instead of every char add:
private Keys lastKeycode;
protected override void OnKeyUp(KeyEventArgs e) { base.OnKeyUp(e); lastKeycode = e.KeyCode; if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Space) { TextHasChanged(); } }
Cut the code under OnTextChanged and place it under a new method TextHasChanged
private void TextHasChanged() { if (lastKeycode == Keys.Return) { SelectionStart -= 1; } //paste OnTextChanged Code here //copied code //paste OnTextChanged Code here ProcessLine(); if (lastKeycode == Keys.Return) { SelectionStart += 1; }
m_bPaint = true; }
Works for me
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
biopsy wrote: use a for each loop to traverse through a line looking for keywords. This is more efficient than using for loops.
All very good suggestions, however, standard indexed "for" loops are more efficient than "for each" loops. There's an old MSDN TV video where the M$ guy that wrote that part of the framework demostrates each and explains that using indexes in a standard "for" loop is faster than "for each". He domstrated this with diagnostic timers. I believe it's somewhere around episode 12. Look for memory optimizations... I think that was the topic. This is all true unless they've updated that portion of the framework and reversed which is more efficient.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi
i unbelive that anyone know how tu put undo command inside?
Is there a possibility for supporting undo / redo after changing the text? the command undo syntaxRichTextBox1.Undo() doesn't work.
thanks.
Luka M.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
Great work Patrik!
There is only one thing I don't like about this control, the lack of C-style commenting. I've tried to edit the regex to /\\*(.*?)\\*/, and modified the settings but I can't get it to work
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Not having looked at the code, can't say for sure, but I would throw a guess out there that the syntax highlighting may be done on a line-by-line bases. This would adequately explain why multi-line syntax highlighting(such as quite a few instances of /*...*/ are) are not supported.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi (again )
I'm having a lot of trouble inserting a specific character in the RTB control.. it just doesn't appear! :'( Tha character is: (is in between the ".. it does'nt even appear here! :'( ""
i think it's charcater Chrw(173) or 00AD
any ideas on how to enable the RTB to use this character?
Thanksd!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi!, ok, i finally managed to create diferent groups of "keywords", i now need to disable the case matching, the language that's edited in th richtextbox it's not case sensitive...
if anybody knows, i'ld be very glad, thanks!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
sorry, i managed to do this, i didn't see that the MDX guys cutted the RegexOptions.IgnoreCase piece of code...
Thanks!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi!
This Syntax Highlighter works really cool!!!!
I was wondering if it's posible to add:
1. an auto complete function 2. undo/redo 3. Line numbering 4. Besides Keywords, comments, strings, and integers is it posible to add other groups like Keywords?
The last request is because i'm developing a Code editor for TI-BASIC (For texas instruments's calculators) and it would be nice to difference keywords from functions, instructions and operators.
I know very little of programming, so, if my requests are out of the blue please forgive me 
PD: Any advice on how to improve the speed???
-- modified at 4:18 Saturday 10th February, 2007
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |