Spin2 editor (now works with P1 & P2)
Rayman
Posts: 14,645
The colored background makes it hard to create a Spin editor...
But, I finally came across some colorizer example code that I was able to understand and twist into shape:
https://www.codeproject.com/Articles/1408/Colorizing-edit-control
It now bolds all Spin1 keywords and sets background colors the right way (I think).
It also recognizes comments.
Update: Fixed keywords for VAR, CON, OBJ sections. Zip updated 7SEP18
Code posted 7Sep18.
Anyway, this is looking like it might work...
A 7-zipped Windows executable is below...
latest Exe (in .7z format) posted 29Sep18.
It requires the Parallax font be installed, but you probably already have it if you use the Propeller Tool.
For P1, it requires propellent to be in same folder as spinedit.exe
for P2, you need p2asm.exe and loadp2.exe (attached in zip file) to be in same folder as .spin2 file
But, I finally came across some colorizer example code that I was able to understand and twist into shape:
https://www.codeproject.com/Articles/1408/Colorizing-edit-control
It now bolds all Spin1 keywords and sets background colors the right way (I think).
It also recognizes comments.
Update: Fixed keywords for VAR, CON, OBJ sections. Zip updated 7SEP18
Code posted 7Sep18.
Anyway, this is looking like it might work...
A 7-zipped Windows executable is below...
latest Exe (in .7z format) posted 29Sep18.
It requires the Parallax font be installed, but you probably already have it if you use the Propeller Tool.
For P1, it requires propellent to be in same folder as spinedit.exe
for P2, you need p2asm.exe and loadp2.exe (attached in zip file) to be in same folder as .spin2 file
Comments
Your text looks to be gray.
I personally don't care for the coloring in proptool, and would prefer a normal syntax coloring scheme.
I'm not seeing any dependence on font forecolor to background color (Prop Tool screenshot attached)
You really have to make a custom highlighter/editor to properly handle everything.
But, you're right that the Prop tool has a lot of details in the coloring, when you look close.
We'll see how hard this is... Wasn't so bad so far...
The major issue was copying back and forth between here and Prop Tool.
Prop Tool uses either ansi or Unicode, but I had to use clipboard in Unicode mode to get circuit symbol characters.
But, this editor is ansi, so I had to make code page lookup table to get circuit symbols in range from 0...255.
I suppose I could change the editor to be Unicode... Still thinking about that one...
I didn't even bother trying to do the coloring like proptool. It just does a basic normal one, but it doesn't yet handle all of the Spin/PASM oddities. It's all built in Qt 5.10 using mostly Qt's built-in editor/highlighter/etc. stuff.
I'm still not sure what to do about the licensing Smile, since Qt is GPL and technically if I integrate OpenSpin(which is MIT) then it will get infected with GPL. I wish things were simpler here. I just want to keep OpenSpin completely MIT licensed, but it would be nice to have it built right into the editor.
Anyway, I'm not sure if I will ever finish it, seems like many others are making spin editors now.
But, this is MFC, so meant for Windows. However, it would probably run under WINE.
I while back I looked at doing the same thing but extended slightly for P2.
I had different backgrounds for COG and HUB exec code.
For example purple for hubexec code and green for cog exec(DAT blocks).
Attached here.
Still a lot to do though... I updated first post with 7z zip file of current version.
It may be hard to faithfully reproduce braces...
I currently have each line assigned a single background color.
But, I see now that braces can cause there to be two different backgrounds on the same line.
I'll have to think about how bad we really need that...
The double apostrophe is a "document comment" and the double brace is a "multi-line document comment".
You see these when you select the "Documentation" radio button at the top of the screen...
The only views I ever use are "Full source" and "Summary". But, I think I can use the "class view" pane to show something similar to summary view, so maybe don't need any of that...
Could this work be applicable to Visual Studio Code ? - or is this pathway limited to a custom editor ?
one example link : https://code.visualstudio.com/docs/extensions/themes-snippets-colorizers
Also, note that you can disable a multi-line comment with a single line one.
'{
this line is not commented out
'}
However, it only disables the opening one, note the below lines are valid:
{
this line is commented out
'}
Or a theme in VScode or Atom like jmg said?
I think you just need to edit the Spin.json file.
But, what I'm attempting here is a close to exact replica of Prop Tool, with all the same colors.
Trying to do operators like ":=" now...
If you look in the preferences for PropTool you can see the categories it uses for coloring things. In there you see repeat is considered a "conditional" (along with if, case, etc.), QUIT is a "command".
It's a little odd how they chose to do it, in my opinion, but it is what it is.
But, it’s a minor point..
Try the 7-zip exe in the first post. It can now open files.
Added flow control and numbers.
Numbers are a bit tricky and it's not 100% the same as Prop Tool, but maybe OK?
But, I am tempted to make it do Spin1 too.
Not sure what the point would be, but having different compiler options would be interesting.
I don't think I've used BSTC, but I'll take a look...