TodayPlus Boards v2

Programming and MOD Forums => Developer's Corner Discussion => Topic started by: tree99 on February 04, 2005, 03:18:46 PM

Title: Text editor with syntax highlighting
Post by: tree99 on February 04, 2005, 03:18:46 PM
I have searched the forum for this subject and it is mentioned a little in the past under other topics, but I have not seen anything specific on this matter.
   I have been looking at some free text editors that do syntax highlighting and code indenting.  They come with preconfigured  preferences to highlight for common programming lanquages  (htm, perl,xml,pascal,etc.)  Some of them offer the ability to create your own preferences for uncommon languages, like TodayPlus skins, and also let you create bookmarks to specific lines of code.  The beauty is that the highlighting and indent features do nothing to the text files, they only  effect the display in that program.  I have seen some that will autofill when you type in code.  This might allow for the automatic insertion of 'else' and 'endif' when you type 'if', a helpful reminder to include the entire statement.

I have started to play with a simple one that only allows for custom highlighting of text strings.  It is called rsEdit.
I have set up highlighing for: // ; == ; if ; else ; endif ; region ; storevar ; var.  It would be much more helpful to find an editor with custom syntax highlighting so that I can set up code matching.  The program would then let me know which 'endif' goes with which 'if'

Some that I have found are, rsEdit, notepad2, Crimson Edit, there are also many more.

Have any of you used any of these kinds of programs?   Do you recommend one in particular?

Thank you, in advance.
-tree99


here is a screen capture of rsEdit, I have only set up display prefs for a few codes:
Title: Text editor with syntax highlighting
Post by: Broesel on February 04, 2005, 03:52:32 PM
I'm using an Editor called SuperEdi, where you allso can use
syntaxhighlighting.

Edit: It's freeware and you can get it here:
http://www.wolosoft.com/de/superedi/

Greetings Broesel
Title: Text editor with syntax highlighting
Post by: Timmy on February 05, 2005, 03:28:45 AM
Broesel,

I've downloaded the program you mentioned immediately, and gave it a look and a try.

Question: how did you get pruple for calcvar/var, and red for endif ?? (If and else are red, but endif remains black. I have clicked: Format --. File Type --> Java.

Timmy
Title: Text editor with syntax highlighting
Post by: Broesel on February 05, 2005, 04:11:20 AM
Quote from: TimmyBroesel,

I've downloaded the program you mentioned immediately, and gave it a look and a try.

Question: how did you get pruple for calcvar/var, and red for endif ?? (If and else are red, but endif remains black. I have clicked: Format --. File Type --> Java.

Timmy

Timmy, I made en extra definition for txt files, so that if you read a skin
it automatically will be displayed right, I'm looking for the definition-files
and then maybe putting it here in the forum.

Broesel
Title: Text editor with syntax highlighting
Post by: Timmy on February 05, 2005, 04:50:14 AM
Quote from: Broesel
Quote from: TimmyBroesel,

I've downloaded the program you mentioned immediately, and gave it a look and a try.

Question: how did you get pruple for calcvar/var, and red for endif ?? (If and else are red, but endif remains black. I have clicked: Format --. File Type --> Java.

Timmy

Timmy, I made en extra definition for txt files, so that if you read a skin
it automatically will be displayed right, I'm looking for the definition-files
and then maybe putting it here in the forum.

Broesel

Broesel,

That would be nice! I think you have made SuperEdi very readeble by the colours you use in SuperEdi. If you succeed in getting the right defenition file, can you, please, also give a simple advice how to use that file in SuperEdi???

Thanks!
Timmy
Title: Text editor with syntax highlighting
Post by: Broesel on February 05, 2005, 05:26:40 AM
Quote from: Timmy
Broesel,

That would be nice! I think you have made SuperEdi very readeble by the colours you use in SuperEdi. If you succeed in getting the right defenition file, can you, please, also give a simple advice how to use that file in SuperEdi???

O.k. here they come:
Copy the files text.syn and text.col in the syntax-folder of your
Superedi-Installation (f.ex. Programme\Wolosoft\Superedi\Syntax

They are textfiles and can be worked with by Superedi itself. They are
really simple and you will see, how they work, when you read them.

Then rightclicking on the Skintxt-file --> open with superedi will show you
the result.

Broesel
Title: Text editor with syntax highlighting
Post by: Timmy on February 05, 2005, 05:47:35 AM
Quote from: BroeselO.k. here they come:
Copy the files text.syn and text.col in the syntax-folder of your
Superedi-Installation (f.ex. Programme\Wolosoft\Superedi\Syntax

They are textfiles and can be worked with by Superedi itself. They are
really simple and you will see, how they work, when you read them.

Then rightclicking on the Skintxt-file --> open with superedi will show you
the result.

Broesel

Broesel,

Thanks for the two files!!!

I've done everything you told me to do. I even saw that the textfiles are easy to change to everybody's own wishes. But I still have one problem: opening my skinfile with SuperEdi don't give the colours... So I think you changed some other settings in SuperEdi?!? Do you know what settings you've changed in the original version?!?

Thanks!
Timmy
Title: Text editor with syntax highlighting
Post by: Broesel on February 05, 2005, 06:05:56 AM
Quote from: Timmy
Broesel,

Thanks for the two files!!!

I've done everything you told me to do. I even saw that the textfiles are easy to change to everybody's own wishes. But I still have one problem: opening my skinfile with SuperEdi don't give the colours... So I think you changed some other settings in SuperEdi?!? Do you know what settings you've changed in the original version?!?

Thanks!
Timmy

Sorry, did not remember this.
In Superdi under Extras / Einstellungen you have to define that files.
Take a look at the screenshot, this is, how mine is set up.

Broesel
Title: Text editor with syntax highlighting
Post by: Timmy on February 05, 2005, 06:09:56 AM
Broesel,

Thanks!!! That was the last step I'd had to take. Everything works fine now!

Thanks again!
Timmy
Title: Text editor with syntax highlighting
Post by: tree99 on February 08, 2005, 04:06:39 AM
Broesel,

Thanks for your response.  I tried SuperEdi but couldn't get it to code match for tracing if...else...endif statements.   It does a very nice job with the syntax coloring though.

Anyone else who is interested in a great text editor:
I found a very nice program to do both the code matching, code autofill and syntax highlighting.  It is called NotePad++.   I LOVE IT!  Ther website has a lot more screenshots.
http://notepad-plus.sourceforge.net/uk/about.php

Matching works flawlessly, NotePad++ had no problems with nested if...else...endif statements.  The matching allows me to 'roll up' sections of code.   To make sections disappear that I am not working on and to trace if...else...endif statements.   That way I don't have to scroll through so much code when I need to jump back and forth.   Creating bookmarks is another great way to jump back and forth.

NotePad++ also allows me to make a code list for autofill.  I am creating this list from the T+ reference html file.  This helps me make sure I include all the parameters for each function and type the numbers in the correct order.  This is a great reminder for what the numbers refer to.  It also lets me start typing a few characters and then let the computer finish typing the rest of the code.

Here is an animated gif of the program you can see colored syntax and code matching.  Take a look at how I call roll up sections of code.
As you can see the matching of if to endif worked great,  region to endregion did not.  The problem was that region is used in some if statements and so this confused the matching.  The program is case sensitive so I tried to make region into REGION unless it was an argument in another function.  This worked great for matching but made my skin malfunction.  I guess T+ is case sensitive for the region code.  Funny thing, it was fine to make region all caps for some regions, but not all.  To overcome this problem I made sure that all of my REMs were '///' in stead of just '//' and changed the comment setting accordingly.  Then I created a match for //region and //endregion in the setup and added them in the skin file near the //region and //endregion codes.  That worked for matching and T+ didn't mind the odd coding since //region is just REMmed out. Anyway here is the gif.

By the way this is FREEWARE/DONATIONWARE!  They are also improving it all the time.
Title: Text editor with syntax highlighting
Post by: Broesel on February 08, 2005, 04:22:26 AM
Thanks tre99 for this nice finding, especially the code-tracing-feature
makes it worth to give it a try.  :)

Regards Broesel
Title: Text editor with syntax highlighting
Post by: tree99 on February 08, 2005, 04:49:52 AM
Broesel, these files will help you get started.  They go here:

C:\Documents and Settings\USERNAME\Application Data\Notepad++\userDefineLang.xml

and here:

C:\Program Files\Notepad++\plugins\APIs\todayplus.api

The code-tracing is so helpful.  A few years ago( >10 years I think)  I took a C++ class.  I haven't done any programming since, so I remember close to nothing.  I do remember that using a compiler, which helped you trace your code, made things a lot easier than trying to do this stuff with a word processor.
Title: Text editor with syntax highlighting
Post by: Timmy on February 08, 2005, 05:01:07 AM
Tree99,

Thank you for your tip! This evening I'll give this program a try.

Thanks!
Timmy
Title: Text editor with syntax highlighting
Post by: Timmy on February 08, 2005, 11:23:23 AM
Quote from: tree99Broesel, these files will help you get started.  They go here:

C:\Documents and Settings\USERNAME\Application Data\Notepad++\userDefineLang.xml

and here:

C:\Program Files\Notepad++\plugins\APIs\todayplus.api

The code-tracing is so helpful.  A few years( >10 years I think)  I took a C++ class.  I haven't done any programming since, so I remember close to nothing.  I do remember that using a compiler, which helped you trace your code, made things a lot easier than trying to do this stuff with a word processor.

Tree99,

I've downloaded Notepad++ ànd your two files. I've placed these two files in the adviced directories and tested Notepad++

What I think of Notepad++ ? Well, it's a very helpfull program!!! I specially like the if-else help this program gives AND the possibility of printing my skintext in the same colours as Notepad++ shows them AND the easy way of placing/deleting markers.

So, thanks again for your good TIP !


To change the things to my own wishes, can you teach me for example one thing: changing 'else' into green (but not the bold from 'if' and 'endif'). I think I have to use the useDefineLang.xml? But I also saw the word 'else' was in TodayPlus.api?

Timmy
Title: Text editor with syntax highlighting
Post by: tree99 on February 08, 2005, 12:01:22 PM
-Your're Welcome.  I am just glad that I can finally contribute something useful.  I have only been taking from the forum so far, it's nice to give back.

Keep in mind that this program, like all the other syntax text editors, require you to make custom language files.  Those are the files I sent you.  todayplus.api & userDefineLang.xml.  They are not complete in their adjustment, I have missed some codes and am in the process of filling in the rest.  I have most of them inputed and just wanted to help you get started.

 The file todayplus.api needs to be edited with a text editor.  It is simply a text list of codes that your language uses.  I inputed most of these codes as you would see them in a completed skin e.g. button, ; calcvar,.  After trying this out I realized how often I check the reference file for correct syntax. So I started to edit the .api file to have the codes be like this:
button,<x>,<y>,<width>,<height>,<target region>,<action>,<data>,<regions to update>
&
calcvar,var<x>,<system value>
&
calcvar,var<x>,<operation>,<value1>,<value2>
You can decide which is best for you.  Maybe I will list them both ways.

The file userDefineLang.xml is changed by the program itself.  You don't need to do it with a text editor.  Just click the menu: View\User Define Dialog.  A window with tabs and buttons will pop up for you to adjust the keywords, folder words. etc., and the colors of such.  The NotePad++ website is helpful too.
Title: Text editor with syntax highlighting
Post by: uk_skinner on February 08, 2005, 12:06:55 PM
tree99:

 Thanks.
 Your contribution just in time to help me learning PHP scripts.

:approve:
Title: Text editor with syntax highlighting
Post by: tree99 on February 08, 2005, 12:16:02 PM
Uk,

You'll love it for PHP.  That language is already defined.  Just click language and select PHP.  You can get other languages which aren't included in the install on the NotePad++ website.  They are all user contributed.  There are great communities all over the web. :D  I couldn't find T+ skin language, had to do that myself.
Title: Text editor with syntax highlighting
Post by: tree99 on February 08, 2005, 01:04:12 PM
Timmy,

Sorry I missed your question about customizing.

QuoteTo change the things to my own wishes, can you teach me for example one thing: changing 'else' into green (but not the bold from 'if' and 'endif'). I think I have to use the useDefineLang.xml? But I also saw the word 'else' was in TodayPlus.api?

I have posted this I don't know if you saw it:
Quote
The file userDefineLang.xml is changed by the program itself. You don't need to do it with a text editor. Just click the menu: View\User Define Dialog. A window with tabs and buttons will pop up for you to adjust the keywords, folder words. etc., and the colors of such.
I forgot to add that you should choose the language you are modifying in the box at the top of this window.

You have the ability to create 4 groups of keywords.  Each group can be formatted in it's own unique way.  I have most of the codes in group 1, they are light blue.  If you have a code in two keyword groups the formatting will be taken from the lowest number group.  e.g. When else is in group 1 and group 3, the formatting for else will look like  the formatting for group 1.   This also affects folder codes ( code matching).  In order for code matching the code names can not be in a keyword group.  e.g. I have removed if and endif from all keyword groups.  The codes you put in the .api file do not affect the formatting, the .api file is for autofill and words can and should be duplicated here.

The best way to have approached this would have been to make a complete text file of all T+ skin codes.  Each code on its' own line and in alphabetical order.  Save this list as C:\Program Files\Notepad++\plugins\APIs\todayplus.api.  Copy the list to keyword group 1.  Remove all codes from keyword group one that you wish to use for code matching.  Move keywords from group 1 to the other groups as you choose for different formatting.  I don't have a complete codes list yet, I just wanted to get you started.  I was also learning the program on the fly.  Hindsight is always perfect.  When I feel it is complete I will post it.
Title: Text editor with syntax highlighting
Post by: Timmy on February 08, 2005, 05:42:17 PM
Tree99,

You've declared the things very clear to me!!! Thanks for your time! Now I think I'm able to change some things to my own wishes.

Indeed, as you said before: it's a nice program, that makes it easier to handle a skin.txt file or other kind of files.

Thanks again!
Timmy
Title: Text editor with syntax highlighting
Post by: Timmy on February 09, 2005, 02:44:25 PM
 Tree99,

After working and playing for several hours with Note++ I say it again: it's a nice program to work with. In the meantime I've changed all the things to my own wishes.

There's only one thing I couldn't manage. As you said, there should be am autofill feature, using the TodayPlus.api. But that feature don't do it's work. And I couldn't find a key or button in Note++ to fix this. Can you, please, help me another time?

Thanks!
Timmy
Title: Text editor with syntax highlighting
Post by: tree99 on February 09, 2005, 02:57:31 PM
Timmy,

It doesn't automatically autofill like I expected, but it works.  I wish it would start autofilling as soon as you type anything, that way if it matches you pick it.  Instead you begin typing code and then hit ctrl+space, then you will see the autofill pop up and you just scroll to the correct code, this is why the code list in todayplus.api needs to be in alphabetical order.
Title: Text editor with syntax highlighting
Post by: Timmy on February 09, 2005, 03:07:16 PM
Tree99,

Thanks for the explanation!

This is also a nice feature, especially for difficult textlines like:
moontime,%var0%,visible,official,3,-2,HH:mm,, %,l

I'm going to make some of these textlines and put them in the TodayPlus.api to prevent mistakes in the text of my skinfile when typing!

Thanks again!
Timmy
Title: Text editor with syntax highlighting
Post by: Timmy on March 01, 2005, 04:34:11 PM
Tree99,

Again: thanks for your good tip! I'm still using this program with much pleasere. In the menatime I've found three 'If - Endif' errors in my skinfile...

I've also changed the program to all of my wishes, except one:
I haven't find a way to make the 'Blanks' good visible. Do you know a way to make (only) the 'Blanks' well visible???

'Blanks' at the end of textlines can give strange effects, so I'm seeking for a way to easy find them.

Timmy
Title: Text editor with syntax highlighting
Post by: tree99 on March 01, 2005, 07:42:53 PM
Timmy,
I'm glad it has worked out well for you.  I like it too.

To answer your question.  Under View chose 'Show all characters'

This will show a dot where the spaces are and an arrow for tabs.
Title: Text editor with syntax highlighting
Post by: jhollin1138 on March 01, 2005, 09:35:36 PM
@tree99:  I can't believe I missed this topic. :oops: I just wanted to thank you for letting use know about one of the best editor I have ever seen for editing scripts.  I think I have a new favorite editor.  :approve:
Title: Text editor with syntax highlighting
Post by: tree99 on March 02, 2005, 12:25:13 AM
Timmy,

Now I have a question for you.

 What have you done to track the use of region/endregion codes in the folder setup( like how you track if..endif).  I can't use region because there are places where region is used in an if statent .  I explained this earlier when I first posted

QuoteAs you can see the matching of if to endif worked great, region to endregion did not. The problem was that region is used in some if statements and so this confused the matching. The program is case sensitive so I tried to make region into REGION unless it was an argument in another function. This worked great for matching but made my skin malfunction. I guess T+ is case sensitive for the region code. Funny thing, it was fine to make region all caps for some regions, but not all. To overcome this problem I made sure that all of my REMs were '///' in stead of just '//' and changed the comment setting accordingly. Then I created a match for //region and //endregion in the setup and added them in the skin file near the //region and //endregion codes. That worked for matching and T+ didn't mind the odd coding since //region is just REMmed out.

To look at other peoples skins I have to search for all the region and endregion codes and insert my  //region and  //endregion in the preceeding lines.  I also have to replace '//' with '///'

Have you found a better solution?  I would like to not have to write skins in a special way.  It doesn't test the skins syntax correctly, and essentially I have created new syntax, which is probably bad programming behavior.  I could still have a region defined incorrectly and not have Notepad++ catch it.
Title: Text editor with syntax highlighting
Post by: tree99 on March 02, 2005, 12:37:24 AM
jhollin1138,

Again, your welcome.  It is really a small thing to inform everyone about this editor.  I benefit so much from the skins and forum that sharing this seems so little.  If this helps the great skinners out there, I will benefit from the skins.

I found it after getting frustrated with wordpad.  I feel that a computer should do most of the monotonous stuff so I searched for an editor.  I tried some others, but this one worked the best for me.  I do wish that the search/replace was more capable.  The software is under development so maybe a new version will come out that does more.
Title: Text editor with syntax highlighting
Post by: Timmy on March 02, 2005, 10:08:50 AM
Quote from: tree99Timmy,
I'm glad it has worked out well for you.  I like it too.

To answer your question.  Under View chose 'Show all characters'

This will show a dot where the spaces are and an arrow for tabs.
Tree99,

Thanks for you answer!

First I'll answer to your question. No. I didn't find a better way to show the beginning and the end of a region. I only made changes in the colours to make it easier to see. I attached the TodayPlus.api to show you.

Second I have a question for you. I still have problems with the 'Blanks'. The dot for spaces is too small to be easy to view. If you have a better idea: please let me know!

Timmy
Title: Text editor with syntax highlighting
Post by: tree99 on March 02, 2005, 01:25:57 PM
Timmy,

? to trailing spaces...that is all I know of.  I don't think you can customize the symbols that NotePad++ uses.  I see that you can customize the button icons, but that doesn't help.
When I choose 'Show all characters'  I see a CR and LF that are black-boxed .  these are the end line carriage return marks.  When there are trailing spaces (line 6) you see the dots and then the CR and LF far from the end of your code.  When there are no trailing spaces (line 7) the CR and LF are butted up right next to the end of your code.   So you can look for the space from the end of you line to the black-boxed code

I don't think it allows you to search for end of line so you can't do a search replace for 'spaces followed by end of line' to just an 'end of line'  That can be done with another text editor though.  I have looked at my other text editors but can't find one that does, I know I have done it before, maybe I have done it with MS Word.

Another thought is your zoom level.  You might be zoomed out too far to see the dots well enough.  Under View chose 'Zoom in' or 'Zoom out'  or CTRL+MouseWheel-up/down
Title: Text editor with syntax highlighting
Post by: tree99 on March 02, 2005, 01:29:09 PM
Yeah!!

I am no longer a 'newbie', my status in the forum has changed to 'user'
I must be moving up in the world.  Hey, I've got to be excited about whatever I can get.  LOL
Title: Text editor with syntax highlighting
Post by: jhollin1138 on March 02, 2005, 02:04:32 PM
Quote from: tree99Yeah!!

I am no longer a 'newbie', my status in the forum has changed to 'user'
I must be moving up in the world.  Hey, I've got to be excited about whatever I can get.  LOL
Just 74 more post and you'll be a "Pro." :D
Title: Text editor with syntax highlighting
Post by: Broesel on March 02, 2005, 02:33:42 PM
Well, I just found time to install notepad++ and I must say

it really rocks  8)  8)  8)

Thanks for this nice finding, the if -- endif tracking is really fine

Regards Broesel
Title: Text editor with syntax highlighting
Post by: tree99 on March 02, 2005, 02:59:20 PM
I said I would post my definition files so that you could get started using this editor quickly.  Obviously you will want to familiarize yourself with how to customize the language definitions to your preference or to fix any of my mistakes.
I have updated the language definition files in an earlier post.

http://www.jhollin1138.com/forums/viewtopic.php?p=12800#12800
Title: Text editor with syntax highlighting
Post by: Broesel on March 02, 2005, 03:17:57 PM
Quote from: tree99I said I would post my definition files so that you could get started using this editor quickly.  Obviously you will want to familiarize yourself with how to customize the language definitions to your preference or to fix any of my mistakes.
I have updated the language definition files in an earlier post.

Thanks, I downloaded your files already and changed some things to my
needs  :D

Regards Broesel
Title: Text editor with syntax highlighting
Post by: Timmy on March 02, 2005, 05:12:07 PM
Quote from: tree99Another thought is your zoom level.  You might be zoomed out too far to see the dots well enough.  Under View chose 'Zoom in' or 'Zoom out'  or CTRL+MouseWheel-up/down
Tree99,

Thanks for your answer! Yes, I think 'Zoom' is the only possibility to find the 'blank-dots' more easy.

Timmy