Code folding for text outlines?

Code folding for text outlines?

4
NewbieNewbie
4

    Mar 16, 2007#1

    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

    6,603548
    Grand MasterGrand Master
    6,603548

      Mar 17, 2007#2

      Sorry, but this is not possible at the moment. (Later introduced with UE v18.10, read below). 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.
      Best regards from an UC/UE/UES for Windows user from Austria

      4
      NewbieNewbie
      4

        Mar 17, 2007#3

        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

        6,603548
        Grand MasterGrand Master
        6,603548

          Mar 17, 2007#4

          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.

          Code: Select all

          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.
          Best regards from an UC/UE/UES for Windows user from Austria

          4
          NewbieNewbie
          4

            Mar 17, 2007#5

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

            x_hobbes

            236
            MasterMaster
            236

              Mar 18, 2007#6

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

              4
              NewbieNewbie
              4

                Mar 18, 2007#7

                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

                5
                NewbieNewbie
                5

                  Mar 25, 2008#8

                  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 UltraEdit. 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 UltraEdit someday before i retire..

                  1

                    Sep 19, 2008#9

                    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 syntactical 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 ( e.g. 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 different colored groups of line comments ... and able to specify up to five different "ALT"s in each colored group.

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

                    [email protected] <- remove the first letter from my address if you want to sent me an email, thanks.

                    6,603548
                    Grand MasterGrand Master
                    6,603548

                      Sep 20, 2008#10

                      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 writing 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.
                      Best regards from an UC/UE/UES for Windows user from Austria

                      1

                        Feb 18, 2009#11

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

                        1
                        NewbieNewbie
                        1

                          Apr 01, 2009#12

                          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.

                          6,603548
                          Grand MasterGrand Master
                          6,603548

                            Apr 01, 2009#13

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

                            Code: Select all

                            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

                              Jun 07, 2012#14

                              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.