Wouldn't be to hard to write a new text editor. Did this program have special features in it?
Not really,it was a standard Text Editor with midi interface. Yes it wouldnt be too hard to do. I would like to write it in C# but not a lot of people have the Framework installed. What language did you have in mind? I might just put together a simple one which supports auto complete and syntax highlighting. Problem is that I dont have enough time.
Last edited by Danial; Jan 21st, 2005 at 07:57 PM.
Current Work:
SynReas (syntax highlighting and intellisense)
Proposed Ideas:
Support for HTML, ASP, and PHP
?Dynamic Menus - Load from file?
?FTP support?
-------------------------------------------------
My main language is VB pre-.NET
I know a very little C++ (not even VC++), so I can't really do anything except tinker with existing code in a C-type language.
Last edited by Disiance; Oct 5th, 2005 at 08:33 AM.
"I don't want to live alone until I'm married" - M.M.R.P
My main language is VB pre-.NET
I know a very little C++ (not even VC++), so I can't really do anything except tinker with existing code in a C-type language.
Well C++ is not my cup of tea, though like you i can do the basic. Its either VB6 or C#. I am pretty busy currently but I should have some time in a month or so. I might give it a shot..
no problem.
I'm currently playing around with a method to get a function/variable box to pop up with the right contents for the object (in this case Response in ASP). I'm going to play with it and see if I can get an efficient routine for loading variables/functions and such for an object.
"I don't want to live alone until I'm married" - M.M.R.P
no problem.
I'm currently playing around with a method to get a function/variable box to pop up with the right contents for the object (in this case Response in ASP). I'm going to play with it and see if I can get an efficient routine for loading variables/functions and such for an object.
That sounds great . We will have to design it such a way so we can load the defination file for "auto complete" for any other language.
I've got the object definitions part of the file import-feature done. A file to be imported is in the format:
------------------------
[ASP]
[OBJECT=Response]
FUNCTION=Flush
FUNCTION=Write
PROPERTY=Buffer
PROPERTY=CacheControl
[OBJECT=Request]
FUNCTION=BinaryRead
PROPERTY=TotalBytes
--------------------------------
First line defines the code that the page/code type. The rest defines the code objects and then specifies their functions and properties.
I'm thinking the file should also contain information on where code sections start (<% and %> for ASP, <? and ?> for PHP, etc) also so that ASP objects arn't displayed in PHP code.
"I don't want to live alone until I'm married" - M.M.R.P
I was bored and wrote a simplistic editor in C# about a year ago. It was never completed but if you want any features in it I'd be glad to tell you how to do it (though nothing too complex was ever done)
I was bored and wrote a simplistic editor in C# about a year ago. It was never completed but if you want any features in it I'd be glad to tell you how to do it (though nothing too complex was ever done)
#region Auto Tab & Tab as Spaces
private string temp = "";
private int PrevLineSpaces = 0, PrevLineTabs = 0;
private bool _TabsAsSpaces = true;
[Category("BIML")]
[DefaultValue(true)]
[Description("Insert all tabs as a set of spaces")]
[Browsable(true)]
public bool TabsAsSpaces
{
get
{
return _TabsAsSpaces;
}
set
{
_TabsAsSpaces = value;
}
}
private int _AmountOfSpacePerTab = 4;
[Category("BIML")]
[DefaultValue(true)]
[Description("Amount of spaces inserted when the Tab key is pressed")]
[Browsable(true)]
public int SpacePerTab
{
get
{
return _AmountOfSpacePerTab;
}
set
{
_AmountOfSpacePerTab = value;
}
}
private bool _AutoTab = true;
[Category("BIML")]
[DefaultValue(true)]
[Description("Finds whitespace on previous line and inserts it on the next line")]
[Browsable(true)]
public bool AutoTab
{
get
{
return _AutoTab;
}
set
{
_AutoTab = value;
}
}
private void this_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (_TabsAsSpaces)
{
if (e.KeyChar == Convert.ToChar(Keys.Tab))
{
System.Windows.Forms.SendKeys.Send("\b");
for (int i = 0; i < _AmountOfSpacePerTab; ++i)
{
System.Windows.Forms.SendKeys.Send(" ");}
}
}
if (_AutoTab)
{
if (e.KeyChar == Convert.ToChar(Keys.Enter))
{
temp = Convert.ToString(this.Lines.GetValue(this.GetLineFromCharIndex(this.SelectionStart - 1)));
for (int i = 0; i < temp.Length; ++i)
{
if (temp[i] == ' ')
{
PrevLineTabs += 1;
}
else if (temp[i] == ' ')
{
PrevLineSpaces += 1;
}
else
{
break;
}
}
if (PrevLineTabs != 0)
{
for (int i = 0; i < PrevLineTabs; ++i)
{
System.Windows.Forms.SendKeys.Send(" ");
}
}
if (PrevLineSpaces != 0)
{
for (int i = 0; i < PrevLineSpaces; ++i)
{
System.Windows.Forms.SendKeys.Send(" ");
}
}
PrevLineSpaces = 0;
PrevLineTabs = 0;
}
}
}
#endregion
The code above also allows tabs to be inserted as spaces. The nice thing about this code is that it reserves the correct tabs and/or spaces used on the previous line. So if someone has a weird style of Tab Space Space, it'll be used on every following line.
The template system is what I liked best though because anyone can add templates very easily. Just make a folder for the category and name the file appropriately.
If you need anymore help just let me know. I never quite got the handle on syntax highlighting
Last edited by Kasracer; Jan 22nd, 2005 at 03:21 AM.
Something else worth noting is that .Net 1.0 and 1.1 has a bug in which calling Lines.Lenght() in the RichTextBox control erases all undo and redo levels. If you need a reliable way to calculate total and current line, check this out:
Current Line:
Code:
public int CurrentLine()
{
return this.GetLineFromCharIndex(this.SelectionStart);
}
Total Lines:
Code:
public int TotalLines()
{
return this.GetLineFromCharIndex(Int32.MaxValue);
}
Not sure if that is useful to you or not. Again, this code is as if you're writing inside of a class derived from System.Windows.Forms.RichTextBox
Thank you very much for the code -- and that it is well written and easily understandable so I can convert it to VB equivelant. Also thank you for pointing out the RTB's feature that gets the current line, will probably come in handy for line numbers.
"I don't want to live alone until I'm married" - M.M.R.P
Thank you very much for the code -- and that it is well written and easily understandable so I can convert it to VB equivelant. Also thank you for pointing out the RTB's feature that gets the current line, will probably come in handy for line numbers.
No problem. If you need anything else from my program, just let me know.
I am interested in syntax highlighting if you wouldn't mind sharing that when you work on that part. I just couldn't wrap my head around the color changes.
I am interested in syntax highlighting if you wouldn't mind sharing that when you work on that part. I just couldn't wrap my head around the color changes.
Not a problem with me. I really don't have a clue on how to do it, but I know you can. I think that part will be Daniel's job.
"I don't want to live alone until I'm married" - M.M.R.P
Not a problem with me. I really don't have a clue on how to do it, but I know you can. I think that part will be Daniel's job.
kasracer, good to see you back in VBF. No ofcourse not, the editor we are planning to write most probably will be open source. I did have a go at Syntax highlighting in VB6, i have to code some where. Though it was very basic and I need to optimise it a lot before it can be used.
Are you interested in the VB6 code or C# Code, dont think I will try it in C# right now since this editor will be VB6. I would have prefered to do it in C# but the Framework is not installed in most windows machine.
Ok, I *believe* I have converted the code correctly from C# to VB, only a few tests will be able to tell. Unfortuneatly there was one part of the code I could not convert. I couldn't convert the "temp = Convert.ToString(this.Lines.GetValue(this.GetLineFromCharIndex(this.SelectionStart - 1)))" line, the RichTextBox does not have the Lines property/collection. I have attempted using the RevInstr function as well as writing my own version of RevInstr to see if I can pick out the current line, but it seems that I can't get it to work. any ideas? (its the commented out portion below).
VB Code:
Dim TabsAsSpaces As Boolean
TabsAsSpaces = True 'Use spaces instead of tabs
Dim AmountOfSpacePerTab As Integer
AmountOfSpacePerTab = 4 'How many spaces to use in place of one tab
Dim AutoTab As Boolean
AutoTab = True 'Automatically indent
Dim temp As String, PrevLineSpaces As Integer, PrevLineTabs As Integer
Today i spend some time on Syntax Highlighting. I searched for some code on the net, most were tons and tons of code. So I decided to write something on my own. I put together something simple that works, not sure if it will be able to handle large amount of text efficiently. I am gonna do some test tonight if it works reasonable i will post it here.
Any idea a max limit of a RichTextBox? Just want to get an idea how fast is my function with max amount of text..
No, this in C# always referes to the Current Instance of the Parent Object e.g Class/Form.
Ahh, ok, I'll see if I can get the scriptlet working.
I don't know what the RTB's maximum length is.
I'm also working on a system (I call it Syntax Reasoning) that detects whether a word is an object, property, function, or language-reserved word. This will be used for the intellisense, and could also be easily integrated with the syntax highlighting.
"I don't want to live alone until I'm married" - M.M.R.P
Ok, I've gotten the program to extract certain lines.
New problem: When the tab is replaced by spaces, the program doesn't prevent the tab, it just adds the tab and the spaces.. How do I kill the tab?
"I don't want to live alone until I'm married" - M.M.R.P
Today i spend some time on Syntax Highlighting. I searched for some code on the net, most were tons and tons of code. So I decided to write something on my own. I put together something simple that works, not sure if it will be able to handle large amount of text efficiently. I am gonna do some test tonight if it works reasonable i will post it here.
Any idea a max limit of a RichTextBox? Just want to get an idea how fast is my function with max amount of text..
Post your function and we'll see if we can optimize it. Just remember, make sure you only check specific lines. Checking the entire page everytime will be very inefficient and slow.
My idea was to scan the current line for changes on key press and, if there was a " on the line, scan the rest of the document until it finds a closing ".
Originally Posted by Disiance
Ok, I've gotten the program to extract certain lines.
New problem: When the tab is replaced by spaces, the program doesn't prevent the tab, it just adds the tab and the spaces.. How do I kill the tab?
I solved that problem by putting in a backspace before inserting the spaces. In VB.Net, I believe it's different and not the \b used in C#. I'm not sure what it is for VB.Net but insert that before inserting spaces and you'll be fine.
My idea was to scan the current line for changes on key press and, if there was a " on the line, scan the rest of the document until it finds a closing ".
--Excellent idea! Although it won't just check for quotes as it will color things such as "As", "For", "Select Case" in ASP, and then others in PHP. As I stated before I'm working on a system to detect those.
Originally Posted by kasracer
I solved that problem [tabs being entered with spaces] by putting in a backspace before inserting the spaces. In VB.Net, I believe it's different and not the \b used in C#. I'm not sure what it is for VB.Net but insert that before inserting spaces and you'll be fine.
That would work, except that the function is called from VB before the tab is entered. I think I've found a workaround though, a little ugly right now though.
Last edited by Disiance; Jan 24th, 2005 at 12:42 PM.
"I don't want to live alone until I'm married" - M.M.R.P
Post your function and we'll see if we can optimize it. Just remember, make sure you only check specific lines. Checking the entire page everytime will be very inefficient and slow.
Yes indeed, thats what I concluded too, i wrote various functions but they were too slow going through large document. I even tried modifying the RTF. It works fine for Higlighting as you go, but when you paste large document it becomes un-useable.
So i have switched to coloring only visible lines. Just put together some API to get the visible lines now I will try applying my coloring function and see how it goes. I will keep you posted.
I have written a GetLine function Danial. You could pass the cursor's location on KeyPress, then get the altered line, and then just color that line.
Also I believe I have gotten the AutoIndent feature fully operational. I've also added a feature that triggers when the user presses the [BACKSPACE] key, it will then see if multiple spaces should be erased (due to the convert tabs to spaces) I'm going to put it through a few more tests and then post the code here. I'm sure you guys can optimize it a bit, it is a bit ugly -- which brings up another thing. Is there a way to disable the RTB's update until after a function is over?
Could you please send me the function that gets the RTB's visible lines Danial? I assume it would be very useful for line numbers.
"I don't want to live alone until I'm married" - M.M.R.P
I have written a GetLine function Danial. You could pass the cursor's location on KeyPress, then get the altered line, and then just color that line.
Also I believe I have gotten the AutoIndent feature fully operational. I've also added a feature that triggers when the user presses the [BACKSPACE] key, it will then see if multiple spaces should be erased (due to the convert tabs to spaces) I'm going to put it through a few more tests and then post the code here. I'm sure you guys can optimize it a bit, it is a bit ugly -- which brings up another thing. Is there a way to disable the RTB's update until after a function is over?
Could you please send me the function that gets the RTB's visible lines Danial? I assume it would be very useful for line numbers.
Here is my first attempt. Its not 100% complete. Its not accurate yet, I will iron out the bug soon.
Paste some text and test it out.
As for disable RTB's updat, you can do it using LockWindowUpdate API.
That's right, [passing false to the LockWindowUpdate] I remember now. That's been bothering me for a while now
I'll download and look at the code you posted a little later today when I've got more time.
"I don't want to live alone until I'm married" - M.M.R.P
I believe I have the auto-indent feature 100% working, if we can ever catch the other on MSN I'll send you the code. If not I'll send you a PM with a link to it.
"I don't want to live alone until I'm married" - M.M.R.P
ookkkaayyy, it's been a while,, dunno if anyone's still receiving response notifications on this thread anymore...
Reason I never gave updates is because for some reason the subclass method crashed the program on all computers but my own, but I decided to restart the project and have gotten it to work on the rest of the computers. If anyone's still interested than please speak up.
"I don't want to live alone until I'm married" - M.M.R.P
Just in case you didn't find an answer, the RichTextBox doesn't have a text limitation. Apparently it can hold any amount of text, as apposed to the 64k limit of the textbox.
Just in case you didn't find an answer, the RichTextBox doesn't have a text limitation. Apparently it can hold any amount of text, as apposed to the 64k limit of the textbox.
chem
Thank you very much for that info.
"I don't want to live alone until I'm married" - M.M.R.P
What would kick the arse off all other text editors would be to have intellisense.
A couple of editors (such as Notepad++) have autocomplete
The trouble is that it doesn't filter based on what you have previously typed.
Well you know what intellisense is.
Just making the project potentially harder for you
Okay, the project is attached. Nothing of the SynReas is really in at the moment, that is the next step. The other features (like auto-indent and converting tabs to spaces) are in, but there is no options form yet to change them...those are loaded in the frmMain_Load() sub.
"I don't want to live alone until I'm married" - M.M.R.P