Block Group Indicators
Rayman
Posts: 14,619
in Propeller 2
I'm trying to add "Block Group Indicators" to SpinEdit…
BTW: Who came up with that name? Surely, there's a better name for these?
I use this all the time in Prop Tool and really miss them in SpinEdit.
My first attempt was a fail, see image.
Even though I use them all the time, I've never really thought about the logic for drawing them...
I see now that I need these for IF, CASE and REPEAT blocks of code.
Propeller manuals says this for each of these:
Also, drawing these things looks like a pain...
I was trying the font character that is a horizontal line.
It's not so bad. Do we need it like it is in the Prop Tool?
I'm not even sure they are drawing those things...
It might be a special font character or maybe a bitmap image.
Anyway, this is a puzzle right now...
BTW: Who came up with that name? Surely, there's a better name for these?
I use this all the time in Prop Tool and really miss them in SpinEdit.
My first attempt was a fail, see image.
Even though I use them all the time, I've never really thought about the logic for drawing them...
I see now that I need these for IF, CASE and REPEAT blocks of code.
Propeller manuals says this for each of these:
Indention is Critical IMPORTANT: Indention is critical. The Spin language relies on indention (of one space or more) on lines following conditional commands to determine if they belong to that command or not. To have the Propeller Tool indicate these logically grouped blocks of code on-screen, you can press Ctrl + I to turn on block-group indicators. Pressing Ctrl + I again will disable that feature. See the Propeller Tool Help for a complete list of shortcut keys.
Also, drawing these things looks like a pain...
I was trying the font character that is a horizontal line.
It's not so bad. Do we need it like it is in the Prop Tool?
I'm not even sure they are drawing those things...
It might be a special font character or maybe a bitmap image.
Anyway, this is a puzzle right now...
Comments
Honestly, what you have is pretty good. I like those indicators myself.
I would use what you have done gladly. It is just enough.
Actually, Jeff Martin at Parallax made those block indicator lines. I believe he draws them. They are not font characters, although that would be a pretty clean way to do it.
Okay. I'm away from the house. I parse the start of each line for the group keywords and indention, and can the edit control's after-paint event (or something like that) and custom draw the indicators.
Going to be trickier than I thought...
Actually, I guess all the groups work like that... Hmm..
That would be a lot simpler to code, I think...
That doesn't really indicate much.
Think I need to create a TrunkStartCol" List, "BranchEndCol" integer, and a HasIndicator Boolean for each line.
Maybe "Flow Control Indicators" is a better name for these?
Looks like these are the only keywords that can start a block: if, ifnot, else, elseif, elseifnot, case, repeat
I’ve done P1 & P2 word colorisation based on some previous work. I use VSC for python at work. It’s becoming an extremely popular editor and is open source too. It has all the usual editing functions done. There are plugins to tailor the visual experience, as well as rules. For example, it does a pretty good job of debugging your (python) source code as you enter, and when you save the file - highlites errors such as syntax, unused variables, etc. And it has intellisense to prompt for subroutine parameters too.
In Python, groups are recognised and can be closed up by clicking groups “>” in the left column.
Since python is an indented language, it might be worth looking at the python add-in.
https://stackoverflow.com/questions/41898245/visual-studio-code-sidebar-vertical-guideline-customize-sidebar
Looks like this has been implemented so looking now for it
And they've been on my python code all the time - amazing how you just get used to something and don't realise it
Here are some examples, first python, then P1 spin, then P1 PASM. Note the spin and PASM colorisation
Perhaps my color choices need reworking
Prop tool seems to check the first word in a line to decide if it's a group or not...
The inbuilt terminal is way more powerful than just a plain terminal. Might also be useful to utilise this.
VSC can call other programs such as the python interpreter. Not sure how this is done at this time as I've not looked.
Seems to me that a common cross platform open source editor that is actively supported would be a much better way to go than to re-invent the wheel and go it alone!
It is straightforward to convert to Qt or Wx.
Maybe one day, I'll look into that...
that does not fly either. Horizontal or vertical line is not what the goal is.
The way the PropTool does it is very easy on the eyes. Those T's and Corners remove the optical clutter.
Basically the folding editor strategy plus markers. The nested levels and range are more easy to spot if start and end are easy to find.
Since I run full Visual Studio I seldom look at Visual Code, but hell yes it seems to have involved a lot in the last Years.
Gosh even a COBOL mode, it is astonishing how Microsoft change it's Strategy around open source.
I am used to MS but I have some mixed feelings about this.
Somehow they are hugging open source really strong, but I have the creepy feeling that they are hugging right around the neck...
Mike
If you look closely, those vertical lines are reduced intensity so they don’t get in the road, and easy on the eyes. They make grouping if/elif/else very easy to see what belongs to what. In fact it’s so easy I hadn’t even realised they were there and I’ve been using it every weekday for the past year!
Yes, MS have embraced open source, but in a very limited and specific way. IMHO those parts are designed to convert the maximum numbers with the minimum open source. Almost everyone uses editors, so maximum coverage with one product.
They know changes are afoot for Windoze on Intel/AMD so they need to embrace ARM or Windoze could be left behind for the majority of users. Most home users no longer require the big iron. Currently, *nix is still not for most home users, but that could change.
IMHO this is why MS have rebirthed Edge. MS must have a mainstream browser! Chrome is used by the vast majority.
Anyway, I digress....
IMHO VSCode makes the most sense to me as the basic editor for P2. PropTool’s editor section is not going to port to Multiplatform easily. Complex editor functions are already inbuilt in VSC, it’s Multiplatform, and syntax highlighting with user customisation, and intellisense and syntax checking options can be added for spin and PASM - it’s already there for python, C, C++, HTML, etc. VSC has a complex Terminal inbuilt, and can call other programs, and has an inbuilt debugger framework.
I write and run my python programs from within VSC while developing and testing them - they utilise the inbuilt terminal in VSC. I haven’t used the inbuilt debugger, at least yet.
VSC should work nicely with Flexgui and loadp2.
I think maybe they are...
See attached for how main branch vertical line ends at the last case, instead of continuing all the way down.
Aside from these indentation indicators, PropTool has a lot of features I don't think an extension can add in VSC:
- block type-specific background colors
- block type-specific indentation
- "Align" mode (super nice for assembly)
- ROM character chart (obviously less useful on P2)
Also, i'm not sure if that is something an extension can fix, but I noticed that when copy-pasting indented lines underneath a non-indented line, VSC removes the indentation (bizarrely enough, you can fix it by undo-ing once?). Hard to explain, but maybe the attached GIF helps (this of course being a tame example, as the coding style I'm using here, unlike what I'd do for regular PASM, only uses indent for labels, but still)
Anyways, here's an MP4. Have fun downloading that and opening it in VLC, lol
EDIT 2: externally hosted GIFs work. Now enjoy the majesty of this motion picture....
Now, onto the hard part...
While I understand the difference, IMHO that difference is wrong - the lines show what is within the case statement whereas this does not show all the lines in the case statement.
As for the comment about coloring blocks, IMHO having colorising reserved words like if, strings in a different color, comments another, etc, etc is far more useful than having the block background colored although it may even be possible in VSC, just never tried.
I know we all have our favorite editors. I use NotePad++ and now VSC daily, and MS NotePad and ?? often. When editing P1 and P2 I still use PropTool from force of habit. But PropTool is not OS agnostic.
Somebody is keeping track of changes here: https://github.com/rosco-pc/propeller-wiki/wiki/Prop-Tool
Looks like weren't there originally, but added in version 1.0...
Getting closer... The attached looks right...
Case statements are all kinds of messed up though...
I also have to get the colors right, seems there are 4 different colors used...
Oops.. No, it's not right. There should be a line between if and else...
It's very non-standard, and actually harder to read than good color syntax highlighting. Also indent guidelines are great (like standard ones), having the grey arrow things like proptool is meh.
Having bright colored backgrounds with text that is a darker shade of the same colors is harder to read (like the comments in proptool).
That outa be illegal. But, I guess it's not...
I've always been okay with the standard colors -- but they can be modified and saved as a color set. I think customization and saving the color set is a good idea.
Tom, what was the show stopper, exactly?