How can I disable auto-indentation in block comments?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

PlaidFlannel
Posts: 43
Joined: Fri Aug 21, 2020 7:06 pm

How can I disable auto-indentation in block comments?

Post by PlaidFlannel » Tue Feb 02, 2021 7:06 pm

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?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

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

Post by richmond62 » Tue Feb 02, 2021 7:15 pm

If you could post a picture of what you mean
exactly it would be easier to understand.

PlaidFlannel
Posts: 43
Joined: Fri Aug 21, 2020 7:06 pm

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

Post by PlaidFlannel » Tue Feb 02, 2021 7:29 pm

Here is a simple example of such a comment. Some others have more levels of indentation.
BlockComment.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

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

Post by richmond62 » Tue Feb 02, 2021 8:10 pm

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 7397 times
-
on closing this script and then reopening it the indentation is preserved.

I am obviously missing something

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

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

Post by bogs » Tue Feb 02, 2021 8:32 pm

Image
Image

PlaidFlannel
Posts: 43
Joined: Fri Aug 21, 2020 7:06 pm

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

Post by PlaidFlannel » Tue Feb 02, 2021 8:33 pm

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?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

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

Post by richmond62 » 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.

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.
Last edited by richmond62 on Tue Feb 02, 2021 8:45 pm, edited 1 time in total.

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

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

Post by bogs » Tue Feb 02, 2021 8:44 pm

Image
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

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

Post by richmond62 » Tue Feb 02, 2021 8:48 pm

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

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

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

Post by bogs » Tue Feb 02, 2021 9:47 pm

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

PlaidFlannel
Posts: 43
Joined: Fri Aug 21, 2020 7:06 pm

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

Post by PlaidFlannel » Tue Feb 02, 2021 9:56 pm

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Tue Feb 02, 2021 10:39 pm

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 7309 times
Craig

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

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

Post by bogs » Tue Feb 02, 2021 10:40 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

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

Post by jacque » Wed Feb 03, 2021 6:00 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 161
Joined: Tue Feb 23, 2010 10:53 pm

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

Post by bobcole » Thu Feb 04, 2021 12:24 am

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

Post Reply