Spin2 editor (now works with P1 & P2)

RaymanRayman Posts: 8,852
edited September 29 in Propeller 2 Vote Up0Vote Down
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
Prop Info and Apps: http://www.rayslogic.com/
1030 x 1049 - 70K
1130 x 1171 - 107K
1148 x 1176 - 127K
«13456

Comments

  • 154 Comments sorted by Date Added Votes
  • Roy ElthamRoy Eltham Posts: 2,473
    edited August 30 Vote Up0Vote Down
    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.
  • 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
    Prop Info and Apps: http://www.rayslogic.com/
  • It's just comment text that is colored to a darker shade of the background colors.
  • Ok, I see that now... I think I can fix that...
    Prop Info and Apps: http://www.rayslogic.com/
  • 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: 8,852
    edited August 30 Vote Up0Vote Down
    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...
    Prop Info and Apps: http://www.rayslogic.com/
  • 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 crap, 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.
  • 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.
    Prop Info and Apps: http://www.rayslogic.com/
  • 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
    Melbourne, Australia
  • 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,177
    edited August 31 Vote Up0Vote Down
    There is a syntax highlighter file for vim. Made by Andrey Demenev in 2009

    Attached here.
  • RaymanRayman Posts: 8,852
    edited August 31 Vote Up0Vote Down
    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
    Prop Info and Apps: http://www.rayslogic.com/
  • Looks good, Rayman.
  • 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
    Prop Info and Apps: http://www.rayslogic.com/
  • May be easier to change the foreground colour for comment chars ???
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • 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...
    Prop Info and Apps: http://www.rayslogic.com/
  • jmgjmg Posts: 12,414
    edited September 1 Vote Up0Vote Down
    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?
  • 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.
    Prop Info and Apps: http://www.rayslogic.com/
  • I'm getting closer... Added in braces (major pain) and strings.
    Trying to do operators like ":=" now...

    1660 x 1142 - 76K
    Prop Info and Apps: http://www.rayslogic.com/
  • 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...
    Prop Info and Apps: http://www.rayslogic.com/
  • 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.
  • The prop manual groups those together...
    But, it’s a minor point..
    Prop Info and Apps: http://www.rayslogic.com/
  • 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
    Prop Info and Apps: http://www.rayslogic.com/
  • That looks really nice. It would be pretty slick if you could attach your favorite compiler. Ie BSTC.
  • 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...
    Prop Info and Apps: http://www.rayslogic.com/
  • 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.