5

I'm trying to get a better understanding of the *.dsl files as disassembled by the iasl program. Those files looks like:

/*
 * a comment
 */
Stuff
{
    More Stuff
    {
        Beer (a, b) // another comment
    }
    Hmm (mmm)
    {
        Package (0x04)
        {
            0xFFFF
        },

        Package (0x04)
        {
            0xFFFF
        }
    }
    Meh (x, y)
}

This syntax should be really easy for a text viewer / editor. Since I'm just viewing these files, the editing feature is not needed. The file has 11k lines which makes it more difficult to scan for text.

Is there a lightweight text viewer with folding capabilities? Both CLI and GUI solutions are welcome.

Addition: I would like to have the next features too:

  • shortcuts to jump from the child to the parent (e.g. Beer to More Stuff or the { next to it)
  • quick search (till now, I used less in which I can search by pressing / followed by the search term and Enter. The Firefox "on the bottom search" bar is something that I would like to see for a GUI program)
  • bonus: hiding blocks of text

The purpose of the viewer is getting me through the text file faster.

2
  • Bonus: a text viewer in which I can select a whole block of text and hide it (with the possibility to unhide it of course, such a block could be a lot of lines like More Stuff)
    – Lekensteyn
    Aug 3, 2011 at 9:06
  • vim, its like an industrial work shop. with every tool you could ever need. The problem is that the on the job training will take you a few months before you have covered the basics. It will take even longer before you look at all other text editor as primitive, and worth less. One of the best things you can do is to suck it up and learn vim. It will save you hours latter in life. Invest in your self learn vim
    – nelaaro
    Aug 4, 2011 at 8:44

4 Answers 4

7

The editor geany, also useful as an IDE, has indentation based folding for python source files.

It should be a way to associate .dsl files with this type of representation

enter image description here

3
  • Looks great and lightweight indeed. I set the filetype (temporary?) to Python following: Document -> Set filetype -> Scripting languages -> Python. I couldn't find the file association in a few seconds, where can I do that?
    – Lekensteyn
    Aug 3, 2011 at 9:33
  • Is there a keyboard shortcut available to jump to the parent? E.g. from 0xFFFF to the { or Package (0x04). Also, is there a shortcut available to jump back to the last position? I'm used to Komodo Edit which has a "bookmark line" shortcut by pressing F2, does Geany has such a feature too?
    – Lekensteyn
    Aug 3, 2011 at 9:37
  • @Lekensteyn: it is capable to remember (the single file, not the extension), but it is better to use the menu item Tools->Configuration Files->filetype_extensions.conf, add *.dsl; at the end of the Python line and save in ~/.config/geany/, as suggested. No info about keyboard shortcut
    – enzotib
    Aug 3, 2011 at 11:05
5

VIM to the rescue!

You can use VIM to fold methods with a rapid command. In normal mode, type zf2j and you'll get the method folded.

You can associate a key shorcut to the zf2j command and... You are done! :D

EDIT:

Found an interesting table with all the commands related to folding in VIM:

  • zf#j creates a fold from the cursor down # lines.
  • zf/string creates a fold from the cursor to string .
  • zj moves the cursor to the next fold.
  • zk moves the cursor to the previous fold.
  • zo opens a fold at the cursor.
  • zO opens all folds at the cursor.
  • zm increases the foldlevel by one.
  • zM closes all open folds.
  • zr decreases the foldlevel by one.
  • zR decreases the foldlevel to zero -- all folds will be open.
  • zd deletes the fold at the cursor.
  • zE deletes all folds.
  • [z move to start of open fold.
  • ]z move to end of open fold.
2
  • My vote, vim is one of the best text editor to learn and use. It makes so many things faster.
    – nelaaro
    Aug 4, 2011 at 8:46
  • Agree with you. It's my main text editor at work and I use it for my personal projects too! No matter what people say, for me is just what I need: free, customizable and with tons of features due to tons of plugins for whatever you need! :D
    – kerunaru
    Aug 4, 2011 at 13:05
3

GEdit

With a couple of extra plugins such as bookmarks and simple-folding, gedit could be a viable contender.

Bookmark shortcuts - enter image description here

Folding shortcut Alt + Z

enter image description here

How to install

Install the extra plugins

sudo apt-get install gedit-plugins

download the two simple-folding files from sourceforge Save them to .gnome2/gedit/plugins n.b. create the folder if it doesnt exist.

Activate the Bookmarks and Simple-Folder plugins through the menu option Edit --> Preferences --> Plugins

2

For my particular needs (analysing ACPI tables), I've created FoldedViewer:

view.html

It's name is actually FoldedViewer (no trademark infrignment intended if any) and the JS/ HTML5 program is useful for speeding up analys of DSDT/ SSDT tables by providing folding capabilities. If you're using a recent browser, especially if it's open-source like Firefox or Chromium, you'll be able to select files through a file picker.

Features:

  • Fold blocks (determined by indention, Ctrl + Click)
  • Show the number of childs blocks
  • Jump to line number
  • Save the fold state in the browser using localStorage
  • Works from browser, no installation required
  • Opens file from URL or using the file picker of the browser
  • Shows the namespace and object of the block under the mouse position
  • Highlights the current line and selected block
  • Collapse/ expand all blocks with a single Ctrl + Shift + Click

screenshot of FoldedViewer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .