Code folding

Syntax highlighting, code folding, brace matching, code indenting, and function list

Code folding

Postby pietzcker » Tue Feb 08, 2005 9:55 am

Hi,

I can't get code folding (in UE 11.00) to work properly. When I open a PHP file, functions, loops, etc. are folded correctly, so "in principle" it should work. However, in HTML files I get tons of "[-]" next to nearly every tag there is, and clicking them almost never has any effect. E.g. a <table> tag in one line, then several lines of table definition, and a </table> tag a few lines later - clicking on [-] doesn't change anything.

Clicking on the second <tr> tag within the table causes the entire rest of the file to collapse, right until the </html> tag.

This happened with an HTML tidy proofread file, so it's not because of missing "ending" tags that could have thrown UE off course.

Also (of course) Python code folding doesn't work. Python groups sections of code by indentation and de-indentation (exdentation?), and that doesn't seem to be configurable in UE...

Time for an update? ;)
Tim
User avatar
pietzcker
Master
Master
 
Posts: 242
Joined: Sun Aug 22, 2004 11:00 pm

Re: Code folding

Postby fantasynwa » Tue Feb 08, 2005 4:34 pm

Another question on folding. Does folding work for languages other than C/C++? I see that in parenthesis in the feature list, and I use UE almost exclusively for Java, so I wanted to be sure it was for any language (any C based language maybe?).
User avatar
fantasynwa
Newbie
 
Posts: 2
Joined: Mon Dec 13, 2004 12:00 am

Re: Code folding

Postby THEMike » Wed Feb 09, 2005 2:42 am

If you read the help, UltraEdit has fold strings defined for many languages, what you need to do is add JAVA_LANG to your java definition line:

/L1"Java" JAVA_LANG (other crusty stuff)

and it should work.

If it doesn't work for a specific language, then you can just do

/Open Fold Strings = "{"
/Close Fold Strings = "}"

in your wordfile.
User avatar
THEMike
Basic User
Basic User
 
Posts: 15
Joined: Mon Nov 01, 2004 12:00 am
Location: UK

Re: Code folding

Postby bookemdano » Thu Feb 10, 2005 1:47 am

So how do you get multiple fold strings to work?
User avatar
bookemdano
Newbie
 
Posts: 2
Joined: Wed Feb 09, 2005 12:00 am

Re: Code folding

Postby Manni » Thu Feb 10, 2005 3:37 am

By adding them to the wordfile ;-)

Here's an example for using code folding on wordfiles:

Code: Select all
/Open Fold Strings = "/C1" "/C2" "/C3" "/C4" "/C5" "/C6" "/C7" "/C8"
/Close Fold Strings = "/C2" "/C3" "/C4" "/C5" "/C6" "/C7" "/C8" "/L2" "/L3" "/L4" "/L5" "/L6" "/L7" "/L8" "/L9" "/L10" "/L11" "/L12" "/L13" "/L14" "/L15" "/L16" "/L17" "/L18" "/L19"
/Ignore Fold Strings =  "// /"

Manni
User avatar
Manni
Advanced User
Advanced User
 
Posts: 58
Joined: Thu Jul 15, 2004 11:00 pm
Location: Europe

Re: Code folding

Postby bookemdano » Thu Feb 10, 2005 9:38 am

Thanks! Stupid me was using "str1","str2"
User avatar
bookemdano
Newbie
 
Posts: 2
Joined: Wed Feb 09, 2005 12:00 am

Re: Code folding

Postby pietzcker » Tue Mar 22, 2005 5:28 am

I just installed V11.00b and code folding in HTML still produces no sensible results in most cases. E.g. on a <html> tag, it folds six lines until a </b> tag (the </html> tag is way down below). No idea at all what's happening there.

Is there a way to turn code folding off for certain languages?

Greetings,
Tim
User avatar
pietzcker
Master
Master
 
Posts: 242
Joined: Sun Aug 22, 2004 11:00 pm

Re: Code folding

Postby Inray » Tue Mar 22, 2005 8:41 am

Hmm, i have exactly the same issue pietzcker described.

Folding in HTML doesn't work correctly. Actually, UE folding never worked OK for me. Maybe because the algorithm IDM used, or wordfile, or both but it's almost useless for now.

Anyway I'm sure IDM will make the best they can to have it fixed soon.
User avatar
Inray
Advanced User
Advanced User
 
Posts: 52
Joined: Wed Jul 14, 2004 11:00 pm
Location: Europe

Re: Code folding

Postby mary.vivit » Fri Apr 01, 2005 10:21 am

pietzcker wrote:Is there a way to turn code folding off for certain languages?

Though I haven't tried it, you might explore removing the /Open Fold String and /Close Fold String lines in your wordfile.txt for the offending language.
User avatar
mary.vivit
Basic User
Basic User
 
Posts: 35
Joined: Tue Nov 23, 2004 12:00 am

Re: Code folding

Postby Ynfynyty » Mon Apr 04, 2005 4:32 pm

What about defining custom folds?

I don't want curly braces to be the fold points for my php. Instead I want #Region and #End Region to be my fold points, but entering these into the Open and Close fold lines in the wordfile does nothing at all.
User avatar
Ynfynyty
Newbie
 
Posts: 2
Joined: Thu Mar 03, 2005 12:00 am

Re: Code folding

Postby Ynfynyty » Mon Apr 04, 2005 4:54 pm

And this one is great...

Given a comment like

Code: Select all
    /*
    ############################################
    ## PKD - PKD Inc.
    ## Website Code - Functional Include for Ynfynyt Jest dot Com
    ##
    ## Paul Kahl
    ## PHP code started on 4/4/2005 9:32AM
    ## Last Edit: 4/4/2005 9:32AM
    ############################################

    ## environment variable REQUEST_URI
    */

The fold looks like

Code: Select all
    /*

    ## Environment variable REQUEST_URI
    */

And /* and */ aren't even defined in my folds... and FOLDS is the only place this ought to be defined.
User avatar
Ynfynyty
Newbie
 
Posts: 2
Joined: Thu Mar 03, 2005 12:00 am

Re: Code folding

Postby crodgers » Tue Apr 05, 2005 9:24 am

Ynfynyty wrote:What about defining custom folds?

I don't want curly braces to be the fold points for my php. Instead I want #Region and #End Region to be my fold points, but entering these into the Open and Close fold lines in the wordfile does nothing at all.

Maybe you have defined "#" as a comment? Post the part of your word file for that language and maybe someone can help. It seems that many of the configurable options may affect other options. Also possible is that you added the fold strings to the wrong language. PHP files are multi-language files. You must add the #Region and #End Region fold strings to PHP language and not to HTML language. And block comments can be always folded.

As for changing what to fold on, you can do that. I defined keywords that I wanted to fold on for AutoSys JIL. Below is part fo the wordfile:
Code: Select all
/L19"AutoSys JIL" Line Comment = # Block Comment On = /* Block Comment Off = */ Escape Char = \ File Extensions = JIL
/Delimiters = ~!@$%^*()+=/\[]{}:;"<>´` ,   .?
/Indent Strings = "{("
/Unindent Strings = "})"
/Open Fold Strings = "insert_job:"
/Close Fold Strings = "profile:" "alarm_if_fail:"
...


This enables me to fold lines that have those words. For example:
Code: Select all
/* ----------------- odm_ConvStores.0010.000 ----------------- */

insert_job: odm_ConvStores.0010.000   job_type: b
#owner: queue@testcm2
permission: gx,ge,wx,we,mx,me
description: "Create fulloads for stores that have not acked the merged file"
alarm_if_fail: 1


/* ----------------- odm_ConvStores.0010.005 ----------------- */

insert_job: odm_ConvStores.0010.005   job_type: c
box_name: odm_ConvStores.0010.000
command: sendevent -E SET_GLOBAL -G "ODM_CONVSTORES_TMS=`date +%Y%m%d%H%M%S`"
machine: testcm2
#owner: queue@testcm2
permission: gx,ge,wx,we,mx,me
description: "Creates fulloads for stores that have not acked the merge file"
alarm_if_fail: 1

Folds to this:

Code: Select all
/* ----------------- odm_ConvStores.0010.000 ----------------- */

insert_job: odm_ConvStores.0010.000   job_type: b
alarm_if_fail: 1


/* ----------------- odm_ConvStores.0010.005 ----------------- */

insert_job: odm_ConvStores.0010.005   job_type: c
alarm_if_fail: 1
User avatar
crodgers
Basic User
Basic User
 
Posts: 12
Joined: Fri Mar 18, 2005 12:00 am
Location: FL

Re: Code folding

Postby Mofi » Thu Jun 07, 2012 7:00 am

Starting with UltraEdit v18.10 and UEStudio v12.10 a new code folding mechanism is available in UltraEdit for any language - code folding based on indent level.

Code folding based on indent level is automatically used for Python files with file extension PY (in any case). Being more precise for any wordfile containing file extension PY the language marker PYTHON_LANG is set internally in UltraEdit even if this language marker is missing in the wordfile. Code folding based on indent level is enabled automatically for all files with a file extension listed in a wordfile containing either file extension PY or the language marker PYTHON_LANG.

For all other syntax highlighted files code folding based on indent level can be used instead of code folding based on open/close fold strings by adding to the wordfile on first line anywhere between /Lxx"language name" and File Extensions = ... the keyword EnableCFByIndent.

Please note that EnableCFByIndent disables code folding based on open/close fold strings and therefore open/close fold strings definitions in the same wordfile are ignored by UltraEdit / UEStudio.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3936
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Code folding

Postby rhapdog » Thu Jun 07, 2012 11:34 am

The Code Folding by Indent works fabulously. Even in plain text files (I made a word file for plain text that has the EnableCFByIndent keyword) it works, even when no indent strings are defined. It works on how the user indents the document.

This makes it so much easier to work on files. Especially since it is difficult or near impossible to define some of the indents in some languages, as you can't use regex to define them, and, although the indents aren't required, they make for better readability. Being able to now fold those sections is a dream for me.

Now, just got to wait on UEStudio 12.10 so that I can start taking advantage of it in my actual work. It was great playing with it in UE 18.10, but I need UEStudio for my day-to-day work, because I need to compile and debug, among a host of other reasons.

Ah, well. It shouldn't take long now since 18.10 addressed the issues that needed to be addressed.
User avatar
rhapdog
Master
Master
 
Posts: 253
Joined: Tue Apr 01, 2008 10:02 am
Location: Mississippi, USA


Return to Syntax Highlighting