Code Folding for text outlines?

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

Code Folding for text outlines?

Postby x_hobbes » Fri Mar 16, 2007 3:04 pm

I use UE for taking all sorts of notes, usually in a tree/outline format. For example:

Code: Select all
MyList
   Animal
      Cat
      Dog
         Husky
         Yellow Lab
         Golden Retriever
      Elephant
   Food
      Italian
         Pizza
         Baked Ziti
      American
         Cheeseburger
         Hotdog
   Place
      New York
      San Diego
      Chicago
...


I have created a language in the "wordfile.txt" file called "Text" and I use it to control highlighting to make my notes easier to read, etc. I would REALLY like to take advantage of Code Folding to collapse and expand trees like the one above.

Is there any way to setup Code Folding to automatically put the [-] whenever there's an indented child line? Is there some way to configure it in "wordfile.txt" to do this?

Here's what I'd like to do:

Code: Select all
[-]   MyList
[-]      Animal
            Cat
[-]         Dog
               Husky
               Yellow Lab
               Golden Retriever
            Elephant
[-]      Food
[-]         Italian
               Pizza
               Baked Ziti
[-]         American
               Cheeseburger
               Hotdog
[-]      Place
            New York
            San Diego
            Chicago
   ...


Many thanks to anyone that can help figure this out!
x_hobbes
User avatar
x_hobbes
Newbie
 
Posts: 4
Joined: Thu Mar 15, 2007 11:00 pm

Re: Code Folding for text outlines?

Postby Mofi » Sat Mar 17, 2007 1:30 pm

Sorry, but this is not possible. The code folding engine needs specified strings in wordfile.txt which tells the engine, where a block starts and where it ends. It is not possible to let it work just on indentations.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4049
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Code Folding for text outlines?

Postby x_hobbes » Sat Mar 17, 2007 3:33 pm

Wouldn't it be nice if it could do that??? =-)

How hard would it be to code that into it anyway? I think the benefits would be significant!

There's no way to trick it into doing this, huh?

Thanks for your reply.

x_hobbes
User avatar
x_hobbes
Newbie
 
Posts: 4
Joined: Thu Mar 15, 2007 11:00 pm

Re: Code Folding for text outlines?

Postby Mofi » Sat Mar 17, 2007 5:11 pm

No, I don't think this would be very useful for the code folding feature. It would be useful for you because you want to use the code folding engine for a file which is definitely not a source code file.

But if you have enabled the 2 options

Enable show/hide lines and code folding
Enable show/hide lines for non syntax highlighted files


you can use following macro with macro property Continue if a Find with Replace not found enabled and with a hotkey to quickly fold or better hide a text block. If the cursor is currently on a line which you have marked in your example with [-], then pressing the hotkey will select the correct block and hide it. You can make the hidden block visible again by clicking on [+] in the gutter.

Please note: The block which is hid can be wrong if the matching end of a block is not found. In this case the previously hidden block is hid again.

ColumnModeOff
HexOff
UnixReOff
Key HOME
IfColNumGt 1
Key HOME
EndIf
IfCharIs 32
Find RegExp "%[ ^t]+"
StartSelect
Find RegExp Select "%^s[~ ^t]*$"
Else
IfCharIs 8
Find RegExp "%[ ^t]+"
StartSelect
Find RegExp Select "%^s[~ ^t]*$"
Else
StartSelect
Key RIGHT ARROW
Find RegExp Select "%[~ ^t^p]*$"
EndIf
EndIf
HideOrShowLines
EndSelect

Add UnixReOn or PerlReOn (v12+ of UE) at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4049
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Code Folding for text outlines?

Postby x_hobbes » Sat Mar 17, 2007 6:46 pm

I will try that. Thanks very much for your help! =-)

x_hobbes
User avatar
x_hobbes
Newbie
 
Posts: 4
Joined: Thu Mar 15, 2007 11:00 pm

Re: Code Folding for text outlines?

Postby pietzcker » Sun Mar 18, 2007 11:50 am

Mofi wrote:No, I don't think this would be very useful for the code folding feature. It would be useful for you because you want to use the code folding engine for a file which is definitely not a source code file.

Well, maybe in the particular example. But: Python relies on indentation to identify code blocks, so to make code folding available for Python, the only thing the editor can use to determine when a code block begins or ends is when the indentation level changes*. There are some tricks to make a half-baked kind of code folding available for Python, but none of them are really usable. So I very much second the request to make code folding available based on indentation level.

Tim

* Well, they begin after lines that end in ":", so that would be one way to determine when to start a code block. But first, that feature doesn't work in UE since it doesn't seem to care whether the ":" is at the end of the line or somewhere in the middle of it (as in range[2:10]), so it all comes back to the level of indentation...
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

Re: Code Folding for text outlines?

Postby x_hobbes » Sun Mar 18, 2007 2:25 pm

I think UE has potential to grow beyond just the developer community if it implements a few useful features not specific to coding. While I use UE for most of my developing, I find that much of my UE use is not for code -- it's to keep track of notes. My favorite UE features include hanging indent, syntax highlighting, column edit, and regular expressions in search.

I would LOVE to see code folding made usable in outlines -- it just makes sense. Besides, in most code formatting a code block is indented anyway. =-)

x_hobbes
User avatar
x_hobbes
Newbie
 
Posts: 4
Joined: Thu Mar 15, 2007 11:00 pm

Re: Code Folding for text outlines?

Postby bobmcconn » Tue Mar 25, 2008 10:40 am

This is the one feature that I've requested, intermittently, for about a decade now. I've used & use various outlining programs (Action Outline, MyInfo, treepad etc.) and would really rather be able to do this work w/in Uedit. Finding the code folding mechanism kind of accidentally while using the nice SAS code file some good soul created, gave me hope that this feature might become part of Uedit someday before i retire..
bobmcconn
Newbie
 
Posts: 2
Joined: Tue Mar 25, 2008 10:32 am

Re: Code Folding for text outlines?

Postby richwalt670 » Fri Sep 19, 2008 3:05 pm

Not sure if this request belongs in this thread or not ... but this is the closest thread it does belong in based on the search keyword "Outline"

I would like to have syntatical highlighting for simple outlines ... and am working on a wordfile section to that in ( slowly and painfully ... which would have folding as well ).

Code: Select all
I. Major heading Line One ( eg Line all colored Red )
     A. Minor Lines
          1.
              -
              -
          2.
     B.

II.
III

etc ... ( and folding would be nice for levels of abstraction .... say to fold out everything but Romans and Cap Letters etc ... recognized by Tabs )

Some of the color coding of this can be set up with Alts of Line comments ... but it would be nice to have up to 5 differenct colored groups of line comments ... and able to specify upto five different "ALT"s in each colored group.

If anyone knows about other such editors for automatic outlined color syntatical highlighting ... please let me know ... but for now UE is the closest that I know of.

rrich@richimages.net <- remove the first letter from my address if you want to sent me an email, thanks.
richwalt670
Newbie
 
Posts: 1
Joined: Fri Sep 19, 2008 2:56 pm

Re: Code Folding for text outlines?

Postby Mofi » Sat Sep 20, 2008 6:47 am

Rich, I think you simply use the wrong program for your task. All you want is best done with a word processing program like MS Word or Writer of OpenOffice. Such programs are written for editing and writting structured text and applying styles to headings and lists depending on their levels. They also have a structure view. They can also open and save text files (with loosing all format options). And they support macros for example to apply heading and list styles after opening a text file before starting to edit something.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4049
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Code Folding for text outlines?

Postby DanHonemann » Wed Feb 18, 2009 1:59 pm

pietzcker wrote:
Mofi wrote:No, I don't think this would be very useful for the code folding feature. It would be useful for you because you want to use the code folding engine for a file which is definitely not a source code file.

Well, maybe in the particular example. But: Python relies on indentation to identify code blocks, so to make code folding available for Python, the only thing the editor can use to determine when a code block begins or ends is when the indentation level changes*. There are some tricks to make a half-baked kind of code folding available for Python, but none of them are really usable. So I very much second the request to make code folding available based on indentation level.

Tim

I completely agree with Tim. I've been using UltraEdit for years and years, but now that I'm writing scripts in Python, I find myself getting frustrated with this limitation.

Dan
DanHonemann
Newbie
 
Posts: 1
Joined: Thu Sep 25, 2008 1:02 pm

Re: Code Folding for text outlines?

Postby paulo » Tue Mar 31, 2009 8:01 pm

I agree with the above comments that code folding would be very useful in Python. A similar problem exists with YAML files, which is a very useful machine-readable and human-readable format for data. I don't need complete code folding at every level (as suggested by the original poster re text outlines), but simply the ability to fold blocks from the top level. For example, in the following yaml excerpt, I'd like to be able to fold at "aux_types", "debug", or "external_references".
Code: Select all
---
aux_types:
      - aux_type_key_id: 21
        num_votes: 7
        value: "production20081114_0811150057_35_60_383"
      - aux_type_key_id: 91
        num_votes: 3
        value: "production20081114_0811150001_43_43_906"
debug:
    load_action: create
external_references:
      - external_id: "436c5"
        external_source: nlp
      - external_id: "b37af"
        external_source: mdb

Records are separated by three dashes at the left margin, and the top tier of the hierarchy of each record starts at the left margin and ends with a ":". Syntax highlighting would not be useful, and multi-level code folding is not necessary either, but simple code folding would be very useful. I tried to trick the word file into this, but failed.
paulo
Newbie
 
Posts: 1
Joined: Tue Mar 31, 2009 7:07 pm

Re: Code Folding for text outlines?

Postby Mofi » Wed Apr 01, 2009 3:44 am

Well, for the YAML example following fold strings make it foldable except for the last block, here external_references:

/Open Fold Strings = "aux_types:" "debug:" "external_references:"
/Close Fold Strings = "aux_types:" "debug:" "external_references:"

But I guess that was just a simple example and the string on start of a line in a YAML file can be any string.

However, there is the command View - Hide/Show Lines - Hide/Show Selection which can be executed with a hotkey. But I agree that always selecting the block to fold manually is not very user-friendly. But this command is available also as macro command and as script command. So you can write a macro or script which collapse the entire file based on your rules and a second macro or script which folds just the block of current cursor position. Both macros/scripts can have hotkeys for fast execution. So if you need folding for text outlines, you can do it. You have in a macro or script the total control over the rules for selecting multiple lines and fold respecitively hide it.

Once a block is folded it can be unfolded by click on the [+] symbol in the fold gutter.

For example here is a quickly written macro to collapse an entire YAML file. It works for your example. It is surely not perfect, but I don't know anything about the structure of YAML files.

IfExtIs "YAML"
UltraEditReOn
HideShowExpandAll
Top
Find RegExp "%[~ ^t^r^n]*:"
IfNotFound
ExitMacro
EndIf
Key END
Loop 0
StartSelect
Find RegExp Select "%[~ ^t^r^n]*:"
IfFound
Key HOME
HideShowSelection
EndSelect
Key DOWN ARROW
Key RIGHT ARROW
Else
SelectToBottom
HideShowSelection
EndSelect
ExitLoop
EndIf
EndLoop
Top
EndIf
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4049
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Code Folding for text outlines?

Postby Mofi » Thu Jun 07, 2012 6:50 am

Code folding for text outlines becomes possible with UE v18.10 as code folding based on indent level is supported now. Required for code folding on indent level is:

  • The file must be syntax highlighted with a syntax highlighting language. It does not matter if all words in active file are highlighted as normal text because of no words defined in the wordfile containing the syntax highlighting language definition and the color for numbers is set to same as for normal text.
  • The wordfile containing the syntax highlighting language definition for the active file must contain on first line the keyword EnableCFByIndent anywhere between /Lxx"language name" and File Extensions = TXT ...
  • The active file uses for indent what is set at Advanced - Configuration - Editor - Word Wrap/Tab Settings for Default or for files with file extension ???. For details on file extension based indent settings see File extension based word wrap / tab and indent settings.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4049
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Syntax Highlighting

cron