Page 1 of 2

How can I disable auto-indentation in block comments?

Posted: Tue Feb 02, 2021 7:06 pm
by PlaidFlannel
My stack has several objects with lengthy block comments (using /* and */) at the beginning of their scripts. These comments typically have semantic structure that is indicated by indentation (using spaces, not tab characters).

However, when I edit the code below such a comment, the editor frequently changes the block comment to have all lines flush left. This destroys the semantics, and thus the meaningfulness, of the comment.

How can I prevent the editor from doing this?

Re: How can I disable auto-indentation in block comments?

Posted: Tue Feb 02, 2021 7:15 pm
by richmond62
If you could post a picture of what you mean
exactly it would be easier to understand.

Re: How can I disable auto-indentation in block comments?

Posted: Tue Feb 02, 2021 7:29 pm
by PlaidFlannel
Here is a simple example of such a comment. Some others have more levels of indentation.
BlockComment.png

Re: How can I disable auto-indentation in block comments?

Posted: Tue Feb 02, 2021 8:10 pm
by richmond62
If that is a screen shot from the LiveCode scriptEditor there is something very odd about it.

In the LiveCode scriptEditor comment line starts with either '--', '#' or '//" depending on which of those you have chosen in LiveCode's preferences.

I can only see one of those in your screenshot.
-
Screenshot 2021-02-02 at 21.08.02.png
Screenshot 2021-02-02 at 21.08.02.png (17.17 KiB) Viewed 7399 times
-
on closing this script and then reopening it the indentation is preserved.

I am obviously missing something

Re: How can I disable auto-indentation in block comments?

Posted: Tue Feb 02, 2021 8:32 pm
by bogs
Image

Re: How can I disable auto-indentation in block comments?

Posted: Tue Feb 02, 2021 8:33 pm
by PlaidFlannel
Okay, that is interesting.

I'm a LiveCode beginner, and I could not find the syntax for a block comment in the LiveCode Dictionary. A Google search found this Forums post, which contains this line:

You can put /* at the start of the section of code and */ at the end.

I did not notice that that post was from 2007. Apparently, things have changed.

That also might explain why in some of my scripts, the last few lines of a block comment (including the */) are rendered in the various colors as specified by the syntax coloring preferences, while the rest of the comment is rendered in green. It does not explain why the text from /* to */ is, in fact, treated as a comment by the LiveCode interpreter. All those scripts execute correctly.

In the current version of LiveCode, is there syntax for a block comment that does not require special character(s) on every line of the comment?

Re: How can I disable auto-indentation in block comments?

Posted: Tue Feb 02, 2021 8:36 pm
by richmond62
is there syntax for a block comment that does not require special character(s) on every line of the comment?
As far as I can tell, that is exactly the point of bog's picture.

AND, NO that's not very helpful:
-
Screenshot 2021-02-02 at 21.42.16.png
-
However, on page 597 of the user guide, this IS:
-
Screenshot 2021-02-02 at 21.44.31.png
-
BUT, a right pain-in-the bum to find.

Re: How can I disable auto-indentation in block comments?

Posted: Tue Feb 02, 2021 8:44 pm
by bogs
Image

Re: How can I disable auto-indentation in block comments?

Posted: Tue Feb 02, 2021 8:48 pm
by richmond62
"I think Richmond might be a bit confused"

Well, possibly, but NOT about block comments for the very, very simple reason
that I had never come across them until about 10 minutes ago. 8)

AND, who, one might ask, has read through the LiveCode guide as far as page 597?

https://livecode.com/docs/9-5-0/languag ... de-script/
-
Screenshot 2021-02-02 at 21.54.08.png
-
Although, as that refers to LiveCode 8.0 it is a bit out of date.

Re: How can I disable auto-indentation in block comments?

Posted: Tue Feb 02, 2021 9:47 pm
by bogs
richmond62 wrote:
Tue Feb 02, 2021 8:48 pm
Well, possibly, but NOT about block comments for the very, very simple reason
that I had never come across them until about 10 minutes ago.
Well, ok, I won't bring up past threads you were in that mentioned them (since the mentioning was after your posts) :twisted:

Re: How can I disable auto-indentation in block comments?

Posted: Tue Feb 02, 2021 9:56 pm
by PlaidFlannel
richmond62 wrote:
Tue Feb 02, 2021 8:36 pm
is there syntax for a block comment that does not require special character(s) on every line of the comment?
As far as I can tell, that is exactly the point of bog's picture.
Agreed. However, because we both posted simultaneously, I had not seen his response before posting my own.

So, here's where I believe we stand.

1. The syntax /* comment */ is documented as one way to do multiline comments.

2. The LiveCode interpreter handles scripts with such comments correctly.

3. The LiveCode script editor does not handle such comments well when lines in the comment are indented with multiple space characters.

I have not yet been able to create a simple scenario that consistently displays this erroneous behavior. Until I can, I'll postpone submitting a bug report.

Re: How can I disable auto-indentation in block comments?

Posted: Tue Feb 02, 2021 10:39 pm
by dunbarx
Hi.

Attached is the very first block comment I ever made. I always keep comments of all kinds to a minimum so I won't be able to understand what I wrote an hour ago.

But I find no issues with indentation, including after closing and reopening the stack, or quitting LC and starting a new session. However, if I cut the indented block and paste somewhere, indentation is lost.
Screen Shot 2021-02-02 at 4.32.09 PM.png
Screen Shot 2021-02-02 at 4.32.09 PM.png (11.28 KiB) Viewed 7311 times
Craig

Re: How can I disable auto-indentation in block comments?

Posted: Tue Feb 02, 2021 10:40 pm
by bogs
3. The LiveCode script editor does not handle such comments well when lines in the comment are indented with multiple space characters.
Well, I hesitate to suggest this, but aside from what Craig said above, you can turn off 'auto formatting', and that *should* leave your comments alone. The problem is, it leaves ALL of the script alone, and formatting will then be up to you for everything. :shock:

Re: How can I disable auto-indentation in block comments?

Posted: Wed Feb 03, 2021 6:00 pm
by jacque
Block comments were introduced some time ago. I use them primarily for long explanations above handlers.

The tab key will format the handler where the insertion point is, and shift-tab will format the entire script. The only workaround I can think of is to format each handler independently and ignore the block comment. However, the script editor may have its own ideas when you next open the script.

You could submit a bug report, though it may be a low priority item in the general scheme of things.

Re: How can I disable auto-indentation in block comments?

Posted: Thu Feb 04, 2021 12:24 am
by bobcole
Comments are good but I don't use them enough. I had forgotten about block comments.
Here is a little stack that demonstrates how to pull comments from a script.
Only comments that start a line are shown, not comments that are at the end of lines or heavily indented.
The button puts the comments into a field and it puts them into a tool tip of the button.
Just having fun playing with LC,
Bob
ShowComments.livecode.zip
(1.77 KiB) Downloaded 177 times