1 (edited by JohnWasilewski 2017-07-10 09:01:30)

Topic: Could the editor show code 'ranges'?

My topic subject is a poor description of what I write about but i can't think of a better way to express it.
If someone can suggest a better way of describing the topic subject, I'll gladly change it.

I write to ask whether the editor could somehow indicate the extents of code contained within all:
- DO loops,
- IF THEN -to- END IF code ranges
- etc

As a minimum, whenever the cursor is placed in the start line. or the word "DO", "IF" etc is selected, it would be something of a godsend, in complex code, to see the termination line somehow identified, perhaps by highlighting, or by a red line beneath it.

What would be really superb would be, whenever the cursor is placed anywhere within the range of code like this, for the innermost range above and below the cursor, of any DO loops, IF THEN -to- END IF ranges, etc, to light up. 

What I ask sounds like rather a lot of work to accomplish it, but could it go on a long-range wish list?
---
John

Re: Could the editor show code 'ranges'?

Something like this should be possible based on the code folding detection present in the code editor.  The difficulty comes with properly coloring and styling these "ranges" since our current coloring options are relatively limited and simplistic.  Furthermore, users may have noticed that code folding is no longer present in the fixed-format Fortran editor due to the difficulty of calculating the end points when do-loops are based on line numbers.  Fixed-format code folding would have to be reworked properly first.

But the idea is sound.  There are just a number of details that would be necessary to sort out.  Does anyone else have any thoughts?

Jeff Armstrong
Approximatrix, LLC

Re: Could the editor show code 'ranges'?

I use the "indentation guides" in the Editor options for this.

It will identify the range between each code block (do - end do, if - end if etc) provided indentation is used consistently.

Identifying the code blocks based on syntax isn't trivial for Fortran. You have to cope with things like "labels", e.g.

label: if () then
end if label

loop: do
end do loop

I am somewhat familiar with the VIM code for doing this so it can be done. But whether it is better than the indentation route is another matter.

--
David

Re: Could the editor show code 'ranges'?

I try to use indentation consistently but after I've edited a piece of complex code enough times, inserted new loops, shifted things slightly sideways so it all fits, and done this on occasions sometimes separated by long time gaps, the result is not always as elegant and neatly aligned as I would like it to be.

If Jeff were able to make this work, I would find it a really, really helpful addition.

I do see the problem with colour highlighting.

In the same way as open and corresponding close brackets can be found from a slight darkening of the one at the opposite end, dark shading of the termination line would be ideal, when the start of a block is selected, but just any kind of a flag that appears alongside the bottom of the same block would also do. 
---
We don't ask for much, do we Jeff !? !!