Shop OBEX P1 Docs P2 Docs Learn Events
Block Group Indicators — Parallax Forums

Block Group Indicators

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:
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...

528 x 337 - 11K
«1

Comments

  • Chip made his own gui widgets in Delphi.

    Honestly, what you have is pretty good. I like those indicators myself.

    I would use what you have done gladly. It is just enough.

  • cgraceycgracey Posts: 14,133
    edited 2019-12-21 13:40
    potatohead wrote: »
    Chip made his own gui widgets in Delphi.

    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.
  • Did he use basic windows GDI?
  • cgraceycgracey Posts: 14,133
    Rayman, I texted Jeff to ask how he did it. He's not at his computer now, but he texted me this response:

    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.
  • RaymanRayman Posts: 13,851
    edited 2019-12-21 16:28
    Eeek… I just noticed how Prop Tool handles indicators for CASE statement blocks.
    Going to be trickier than I thought...

    Actually, I guess all the groups work like that... Hmm..
    649 x 456 - 33K
  • RaymanRayman Posts: 13,851
    What if the above looked like this (attached)?
    That would be a lot simpler to code, I think...
    468 x 476 - 24K
  • cgraceycgracey Posts: 14,133
    Rayman wrote: »
    What if the above looked like this (attached)?
    That would be a lot simpler to code, I think...

    That doesn't really indicate much.
  • RaymanRayman Posts: 13,851
    edited 2019-12-21 19:09
    Ok, I'll attempt to copy the Prop Tool format...
    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
  • Cluso99Cluso99 Posts: 18,069
    Visual Studio Code runs on Windoze, *nix and Mac so why not use that as the editor base?

    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.
  • Cluso99Cluso99 Posts: 18,069
    edited 2019-12-21 20:46
    Just found this. Wonder if it can be applied to the code window?
    https://stackoverflow.com/questions/41898245/visual-studio-code-sidebar-vertical-guideline-customize-sidebar

    Looks like this has been implemented so looking now for it :)
  • Cluso99Cluso99 Posts: 18,069
    edited 2019-12-21 21:29
    Yes, VSC has them :)
    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 :smiley:
    Perhaps my color choices need reworking :(

    VSC%20indent%20example1.jpg
    VSC%20indent%20example2.jpg
    VSC%20indent%20example3.jpg
    586 x 232 - 41K
    925 x 474 - 84K
    828 x 657 - 92K
  • RaymanRayman Posts: 13,851
    That looks to be another way to do it, but I'm not sure it's exactly the same...

    Prop tool seems to check the first word in a line to decide if it's a group or not...
  • Cluso99Cluso99 Posts: 18,069
    I've just been looking at the latest VSC update info.
    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!
  • RaymanRayman Posts: 13,851
    The core of SpinEdit is standard C++ and the rest is MFC.
    It is straightforward to convert to Qt or Wx.
    Maybe one day, I'll look into that...
  • No @Cluso99,

    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


  • Cluso99Cluso99 Posts: 18,069
    edited 2019-12-22 12:13
    @msrobots,
    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.
  • JonnyMacJonnyMac Posts: 8,918
    edited 2019-12-22 16:38
    I use Geanie for Python -- it uses subtle vertical lines as well. I think the vertical lines are helpful for long blocks of code.

    indent_markers.png
    725 x 411 - 20K
  • RaymanRayman Posts: 13,851
    I'm trying to decide if indenting rules for Python are exactly the same as for Spin...

    I think maybe they are...
  • RaymanRayman Posts: 13,851
    There is one big difference between these vertical lines and the Spin tree...
    See attached for how main branch vertical line ends at the last case, instead of continuing all the way down.
    294 x 478 - 17K
  • RaymanRayman Posts: 13,851
    "CASE" behaves differently than the rest... This is a real challenge here...
  • Wuerfel_21Wuerfel_21 Posts: 4,448
    edited 2019-12-22 18:25
    I myself like VS Code, but I don't think it'd work particulary well for Spin/PASM (compared to P1 prop tool).

    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)
    412 x 436 - 136K
  • Wuerfel_21Wuerfel_21 Posts: 4,448
    edited 2019-12-22 18:39
    uhmm, could the forum please not break my GIF files, thanks?

    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....
    ckGfl5Q.gif
  • RaymanRayman Posts: 13,851
    Think I have the first level working using the Parallax font to draw the tree.
    Now, onto the hard part...
    509 x 596 - 35K
  • Cluso99Cluso99 Posts: 18,069
    Rayman wrote: »
    There is one big difference between these vertical lines and the Spin tree...
    See attached for how main branch vertical line ends at the last case, instead of continuing all the way down.

    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.
  • RaymanRayman Posts: 13,851
    edited 2019-12-23 20:54
    Was wondering how long "block group indicators" have been around...
    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...
    512 x 327 - 11K
  • Roy ElthamRoy Eltham Posts: 2,996
    edited 2019-12-23 21:22
    I personally don't think it's a good idea to try and match PropTool coloring.
    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).
  • RaymanRayman Posts: 13,851
    Shoot... Thought I had it... Then, saw that a "case" can start a block...
    That outa be illegal. But, I guess it's not...
    1149 x 624 - 90K
  • Roy Eltham wrote: »
    I personally don't think it's a good idea to try and match PropTool coloring.
    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).

    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.
  • I just have to say, "I'm so glad this is getting attention!" This was a drop-dead show stopper for me.
  • cgraceycgracey Posts: 14,133
    I just have to say, "I'm so glad this is getting attention!" This was a drop-dead show stopper for me.

    Tom, what was the show stopper, exactly?
Sign In or Register to comment.