Live data from Hacker News

Code Browser – A Folding Text Editor

tibleiz.net

11–20 of 29 posts

Re: Code Browser – A Folding Text Editor

#13
post #10

First off, this is a really interesting project. However, I'm trying to get my head around how much this would help me. Has anyone used text folding in production?

Eclipse user here. The Java editor does have folding but I find it's much easier to navigate by doing a incremental find (Ctrl-S in emacs mode) or jumping to declarations or uses of a particular symbol. Looking through source by reading words is too slow; even the outline sidebar with method names is not that useful.

The last time I used folding and actually liked it was with GFA Basic on Atari ST :-)

Re: Code Browser – A Folding Text Editor

#15
post #9

Interesting--the author developed his own language with LLVM with which to write the editor: http://tibleiz.net/copper My first reaction reading about the program was: since code folding (and other crutches intended to aid refactoring[1]) ought to be tightly coupled to the language (or even specific project) you're editing, you'd surely need the ability to write scripts, lest things begin to get clunky. Emacs immedia…

Also interesting that Copper is self hosted (written in Copper).

Re: Code Browser – A Folding Text Editor

#16
post #9

Interesting--the author developed his own language with LLVM with which to write the editor: http://tibleiz.net/copper My first reaction reading about the program was: since code folding (and other crutches intended to aid refactoring[1]) ought to be tightly coupled to the language (or even specific project) you're editing, you'd surely need the ability to write scripts, lest things begin to get clunky. Emacs immedia…

To answer my own questions about the intended use for "Code Browser", see:

http://tibleiz.net/code-browser/tips.html

Understanding existing source code

Code Browser can help you to understand existing source code.

There is a lot of tools dedicated to program understanding that will do the job better than Code Browser, but if the source code is written in a too obscure language or too old, it can be a cheap alternative.

Here is some tips to make more sense of a flat text file by extracting a structure and reducing its apparent complexity:

Re: Code Browser – A Folding Text Editor

#17
post #16
post #9

Interesting--the author developed his own language with LLVM with which to write the editor: http://tibleiz.net/copper My first reaction reading about the program was: since code folding (and other crutches intended to aid refactoring[1]) ought to be tightly coupled to the language (or even specific project) you're editing, you'd surely need the ability to write scripts, lest things begin to get clunky. Emacs immedia…

To answer my own questions about the intended use for "Code Browser", see: http://tibleiz.net/code-browser/tips.html Understanding existing source code Code Browser can help you to understand existing source code. There is a lot of tools dedicated to program understanding that will do the job better than Code Browser, but if the source code is written in a too obscure language or too old, it can be a cheap alternativ…

Another text editor that treats text as having no grammatical structure (it doesn't even do syntax highlighting), but nevertheless attempts to give the user some really snazzy shortcuts--not keyboard shortcuts, but mouse shortcuts--is Acme[1].

In fact, years ago, I'd contemplated adding text folding to Acme by adding another chord. I don't exactly remember what I had in mind, but one approach that immediately comes to mind now is to have the chord cut the selected text, and then insert in its place a shorter block of predefined text which starts with the name of an rc script to create a file[2] representing a new "fold" containing the cut text, and positioning the cursor immediately after the command. The user would immediately type a name for the fold, and middle click the whole string to execute the script with the name as its argument, thereby creating the fold. Finally, the selected command just executed should be replaced simply with the name of the fold, which should then be selected, so that the user would now be only a right click away from immediately unfolding the text.

I think the reason I never got around to doing it was that it seemed that this kind of feature really begs for acme to follow the names of the synthetic files representing the "folds" as files themselves to be opened (via right click, which always opens a file in acme), but at the same time, not literally open the file, instead unfolding it.

Writing this comment makes me think now that it wouldn't be so hard to get the semantics of the synthetic "folding" filesystem right, so that Acme remains simply a text editor with a few conventions for working with files, with the "fold" synthetic filesystem doing the work to preserve this simple worldview. What actually concerns me more is the kind of code that would require you to fold it! If need to fold a significant amount of code in order to make sense of your source code, perhaps you would be better if if actually reorganized your project's file structure, and not rely on fancy text editor features as a crutch.

[1] http://acme.cat-v.org/

[2] Of course this feature would use a filesystem to manage the code folds! It's a Plan 9 program, after all.

Re: Code Browser – A Folding Text Editor

#18
post #10

First off, this is a really interesting project. However, I'm trying to get my head around how much this would help me. Has anyone used text folding in production?

Isn't this a standard feature in most text editors / IDEs? I use SHIFT+ALT+CMD+ARROW-LEFT (I think that's the one (muscle memory)) every day in Xcode. And Sublime can fold methods etc also.

Am I missing something?

I do like the tree structure it gives you, something I'd really enjoy having for my notes as an overview. Too bad it's not for OSX.

Re: Code Browser – A Folding Text Editor

#20
I've been trying it out. Here are my suggestions for improvement:

There should be a simple mouse way to exit a section (the opposite of double-click to enter a section)... perhaps an X button to click on. Right now you have to hit Alt-Left, Go->Parent_Section or Right-click menu-> parent. You can navigate quickly when a list-view is open, but this would allow it even if there is no list-view.

The editor should remember the last cursor position within each section. So if I exit a section, then re-enter it, the cursor is restored to the last place.

It would be cool if the editor tried to hide the distinction between files within a project and sections. The project could provide the level of hierarchy above the file. I was surprised that there is no project file .cbp for the code-browser source code.

How can I close a project? It does not seem possible. The "add file to project" should allow me to select multiple files.

I know there are links.. but they don't act like sections. I can Alt-Right to follow a link, but I can't then hit Alt-Left to get back. BTW, when I edit a path for a link it should bring up a file browser, not just a text box.

EDIT: thinking more about this: the concept of tabbed file browsing should be replaced with tabbed views. I should be able to have multiple views into several sections of a project, ignoring all file boundaries.

I should be able to have several views on the screen at one time (even if they are in the same file).

Post reply on HN