Shop OBEX P1 Docs P2 Docs Learn Events
Spin2 editor (now works with P1 & P2) — Parallax Forums

Spin2 editor (now works with P1 & P2)

RaymanRayman Posts: 14,645
edited 2018-09-29 21:49 in Propeller 2
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
1030 x 1049 - 70K
1130 x 1171 - 107K
1148 x 1176 - 127K
«13456

Comments

  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2018-08-30 16:41
    The comment text is supposed to be colored using a different shade of the background color.
    Your text looks to be gray.

    I personally don't care for the coloring in proptool, and would prefer a normal syntax coloring scheme.
  • RaymanRayman Posts: 14,645
    Coloring is easy to turn off... Could be an option...

    I'm not seeing any dependence on font forecolor to background color (Prop Tool screenshot attached)
    222 x 314 - 4K
  • It's just comment text that is colored to a darker shade of the background colors.
  • RaymanRayman Posts: 14,645
    Ok, I see that now... I think I can fix that...
  • At one time I had tried to make something that did all the coloring from Proptool, and it was a giant PITA. Also, getting all the syntax coloring working right is hard with Spin/PASM since they use the same symbol for different things, and comment nesting stuff is oddball compared to anything else. You can "turn off" a { or {{ comment by preceding it with a '. Every other language that I am aware of can't do that, and no syntax highlighting system (e.g. notepad++, etc.) can really handle that by default.

    You really have to make a custom highlighter/editor to properly handle everything.
  • RaymanRayman Posts: 14,645
    edited 2018-08-30 17:27
    This is very custom (as I have to hand code the colorizer...)

    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 think you'll want the editor to be unicode.
  • I started on an editor/proptool replacement that uses OpenSpin a while back. I haven't gotten super far, but it does have all the code for detecting Props and downloading to them (from the proploader project) integrated. I have OpenSpin about half integrated (not functional yet).
    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.
  • RaymanRayman Posts: 14,645
    The colorizer I started from has something like MIT license. So, there's no GPL here.
    But, this is MFC, so meant for Windows. However, it would probably run under WINE.
  • Looks good Ray. I can imagine its non trivial to get this coloring reliably.
  • Nice work Ray.
    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).
    1272 x 370 - 94K
  • TorTor Posts: 2,010
    Has anyone come up with an Emacs (or XEmacs) mode for Spin yet? That would be more convenient for me - I don't use IDE editors, it's better to stick with the one I'm using for everything else. Likewise for vi(m) users.
  • Heater.Heater. Posts: 21,230
    edited 2018-08-31 16:33
    There is a syntax highlighter file for vim. Made by Andrey Demenev in 2009

    Attached here.
  • RaymanRayman Posts: 14,645
    edited 2018-08-31 17:22
    It took some rearranging, but I think I have the comment colors right now...
    Still a lot to do though... I updated first post with 7z zip file of current version.
    1346 x 908 - 65K
  • cgraceycgracey Posts: 14,152
    Looks good, Rayman.
  • RaymanRayman Posts: 14,645
    Thanks!

    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...
    350 x 218 - 5K
  • Cluso99Cluso99 Posts: 18,069
    May be easier to change the foreground colour for comment chars ???
  • RaymanRayman Posts: 14,645
    Wow, I'm noticing things about single line comments and multi-line comments that I never noticed (or didn't care about before maybe...)

    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...
  • jmgjmg Posts: 15,173
    edited 2018-09-01 00:38
    Rayman wrote: »
    ...
    It now bolds all Spin1 keywords and sets background colors the right way (I think).
    It also recognizes comments.
    Update: Fixed comment colors to match Prop Tool. New zip added 31Aug81.


    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
  • Rayman,
    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
    '}

  • Why don’t we use that : http://developer.parallax.com/propelleride/

    Or a theme in VScode or Atom like jmg said?
  • RaymanRayman Posts: 14,645
    PropellerIDE would be very easy to modify for Spin2.
    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.
  • RaymanRayman Posts: 14,645
    I'm getting closer... Added in braces (major pain) and strings.
    Trying to do operators like ":=" now...

    1660 x 1142 - 76K
  • RaymanRayman Posts: 14,645
    I just noticed that flow control statements are sometimes made gray and sometimes treated as regular keyworks… e.g., "repeat" is gray but "quit" is not...
  • Ray,
    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.
  • RaymanRayman Posts: 14,645
    The prop manual groups those together...
    But, it’s a minor point..
  • RaymanRayman Posts: 14,645
    I think it's pretty close now!
    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?

    1030 x 1049 - 70K
  • That looks really nice. It would be pretty slick if you could attach your favorite compiler. Ie BSTC.
  • RaymanRayman Posts: 14,645
    I'm meaning to turn this into a Spin2 editor...

    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...
  • I use BSTC at the moment due to its compression feature. Otherwise it can’t compile due to file too large. Different Loaders is cool too. FTDI, Silabs etc. all these can be linked with simple scripts to access command line tools. For example have a button that you can define for compile and a button to define for loader. Thats sort of what I have on my editor.
Sign In or Register to comment.