Topic: Editor highlighting button

Feature request
Would it be possible to add a button to the editor to enable us to highlight parts of a source file?  Highlighting should obviously be ignored by the compiler, but it would be a very useful aid to visual debugging. 
A facility to highlight selected text in a drop-down-selected colour would be ideal, although even if we were limited to, say, yellow, it would still be very useful.

It would also be ideal if highlighting was saved when a file was saved, but this is also 'dowithoutable'.

Usefulness
A problem I often have to correct is an error message about incorrect nesting of loops.  I search and search through the code, visually tracking the beginning and end of each DO and each IF.  Errors in simple nesting aren't so hard to correct but when there are sequential as well as nested DOs and IFs, and when they straddle more code than I can fit on one screen, so I have to keep scrolling, it is very difficult to keep track!

I currently use the mouse to select a block of code and 'grow' my selection outwards (upwards and downwards) from the innermost loop but I can't multi-select separate blocks.  Highlighting would be a great improvement over this.
---
John

2 (edited by davidb 2014-11-20 18:20:08)

Re: Editor highlighting button

Hi John,

I usually have syntax highlighting turned on for the whole file.

To help with mismatches in if-end if blocks, try turning on Editor options "Indentation Guides" and/or "Enable Code Folding".

Will have to wait and see if Jeff thinks syntax highlighting on parts of a file would be possible or not. I think it might be hard.

What Jeff could possibly do would be to have a "syntax level" number instead instead of the "line number" as an option so you could see how the blocks are numbered, for example

1  If (Flag) Then

       ... etc

2      if (a > 0.0) Then

        ... etc

2      else
3         if (c < 2.0) then
4            do i=1,10
                 .. etc
4            end do
3         end if
2      end if

But the use of indentation guides, a consistent indent and tab policy and and code folding should suffice really.

PS. Jeff, we need a "collapse all" and "open all" option somewhere (control key, menu) to go with the folding.

--
David

Re: Editor highlighting button

I actually don't have a problem with what John is suggesting, but I think it would work slightly differently.

Coloring text in our editor is actually quite difficult because there is already a lot of code making those "styling" decisions.  There is a lexer engine that determine what colors/fonts/styles text should have in the editor based solely on the language being edited and the content of the editor.  Trying to override the styling by, for example, changing the background color of a region in the editor means that the lexer styling has to actually be intercepted and changed prior to display.  While possible, it's effectively a big pain to do.  Underlining things is no problem because that's actually setting an additional, specialized style.

I think a better way would be to do so in the margins, perhaps where the line numbers are displayed, perhaps in an additional margin (there are currently three being used: line number, code folding, and debugging symbols).  It would effectively achieve what John is looking for without actually having to touch the editor styling.  Does that sound like it might work?  I've also been toying with the idea of adding bookmarks to the editor as well, which would also reside in a margin.

David,  I strongly agree about the "expand/collapse all" code folding options.  I am always collapsing giant routines by mistake and scrolling way back up to find the expand button.  I also think collapse should work unless you click on the actual minus sign rather than just in the margin anywhere.

Jeff Armstrong
Approximatrix, LLC

Re: Editor highlighting button

Sounds all good.
--
J.

Re: Editor highlighting button

Bookmarks, as explained in my last post, are now implemented in the development version.

Jeff Armstrong
Approximatrix, LLC