Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Keep comments/formatting? #31

Open
NoSloppy opened this issue Jan 30, 2022 · 9 comments
Open

Request: Keep comments/formatting? #31

NoSloppy opened this issue Jan 30, 2022 · 9 comments

Comments

@NoSloppy
Copy link
Contributor

Currently, when clicking on the right hand column, the style box gets formatted to the bare minimum of that structure
(which is good usually!)
Is there a way to have something like a toggle button "Preserve formatting" that would lock the edit area and allow comments and indentations to remain in the left side style box?

@profezzorn
Copy link
Owner

Comments are now kept.
Formatting is not.

@NoSloppy
Copy link
Contributor Author

NoSloppy commented Mar 22, 2023

Cool that was a lot of work it seems.
Nice to see the comments are also added to the right hand column.
However, now the test results.
Using this as an example:

StylePtr<Layers<  
  // Base
  Red,
  // Force
  TransitionEffectL<TrConcat<TrFade<600>,Blue,TrFade<800>>,EFFECT_FORCE>,
  // Ignition and Retraction
  InOutTrL<TrWipeX<Int<400>>,TrWipeInX<WavLen<EFFECT_RETRACTION>>>,
  // On-Demand Battery Level
  AlphaL<TransitionEffectL<TrConcat<TrSmoothFade<500>,Green,TrSmoothFade<1000>>,EFFECT_BATTERY_LEVEL>,Ifon<Int<0>,Int<32768>>>>>()

then hitting submit, we get this:

Layers<
Red,  // Base
TransitionEffectL<TrConcat<TrFade<600>,Blue,TrFade<800>>,EFFECT_FORCE>,  // Force
InOutTrL<TrWipeX<Int<400>>,TrWipeInX<WavLen<EFFECT_RETRACTION>>>,  // Ignition and Retraction
AlphaL<TransitionEffectL<TrConcat<TrSmoothFade<500>,Green,TrSmoothFade<1000>>,EFFECT_BATTERY_LEVEL>,Ifon<Int<0>,Int<32768>>>,  // On-Demand Battery Level>

The comments get appended to the end of the (sometimes very long) layer.
Is that what you meant by "comments are kept, formatting is not?"

  1. I feel this somewhat defeats the purpose as they won't be visible on the line above the layer they describe and
  2. it breaks things and we get "Expected identifier or number" because the last layer's comment got incorporated between a trailing comma and a closing bracket.

So is it possible to keep the comments in place where they were?

Additionally, now it's not allowing isolation of arguments in the right hand column.
So for example, clicking a color DOES isolate the color in the style box, but the whole RH column is still highlighted, so therefore selecting a new color either by clicking a color tab or by manually entering a new color wipes out the whole thing you had, leaving you with just the new color.

@profezzorn
Copy link
Owner

The easy thing to do is just to always put the comments before the layer.
That will fix most of these problems I think.
Might also simplify the code quite a bit.

@profezzorn
Copy link
Owner

There are probably still things that needs fixing, but comments are now handled in a more sane way I think.

@NoSloppy
Copy link
Contributor Author

NoSloppy commented Mar 24, 2023

Looking good!
The only hiccups I can see now are:

  1. if the user puts a comment mid-layer, it gets added nicely where it belongs in the structured view, however it's not on a newline by itself in the style code box. Interestingly to me, this does not break compiling, I assume since there's a terminal close to the comment and it knows to pickup where it left off?
    Anyway, here's a visual (which is fine if we leave it like this?)
    Example in first layer here:
Layers<
        TransitionEffectL<TrConcat<
        // Impact Flash
        TrInstant,GreenYellow,TrDelay<25>>,EFFECT_BLAST>,
        // Waves
        BlastL<White,850,250,351>
>

becomes

Layers<
  TransitionEffectL<TrConcat</* Impact Flash */ TrInstant,GreenYellow,TrDelay<25>>,EFFECT_BLAST>,
  /* Waves */
  BlastL<White,850,250,351>>
  1. Hitting Expand wipes out the comment.
    Example, selecting BlastL in the structured view gives this in the code box:
    /* Waves */ BlastL<White,850,250,351>
    hitting expand result:
    AlphaL<White,BlastF<850,250,351>>

@NoSloppy
Copy link
Contributor Author

Another thing I found is if there are 2 comments an 2 consecutive lines that are not meant to go together, but happen to be a newline situation, they get grouped and both moved to the beginning of the layer.
Not sure if there's anything to be done about that. How would we know they're not meant to go together?

@profezzorn
Copy link
Owner

Comments are assumed to belong to some code, usually the next code.
I'm not sure why you would write two comments in a row there that "are not meant to go together" though.

@NoSloppy
Copy link
Contributor Author

Agreed. The oddball case is something like commenting the end of a section, like

EffectSequence< EFFECT, first thing,
second thing,
third thing> // end EffectSequence
// This is the Clash layer
ResponsiveClashL<White,TrInstant,TrFade<200>,Int<26000>>,

@profezzorn
Copy link
Owner

Interesting point.
There is already special cases for end-of-line comments, like

Gradient<
Red, // first color
Blue, // second color
Green, // third color

But if the final > is before the last comment, like:

Gradient<
Red, // first color
Blue, // second color
Green> // third color

Then it doesn't work, at least not as currently written.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants