Code Folding?
-
Hello again :)
I need something like code folding feature of Qt Creator for my widget. Its a subclass of QPlainTextEdit with some additional syntax highlighting and line numbering. It should hide text between some environment declaration statement and when user requests show them again. Line numbering should not be affected. For example the text between .begin[signal] and .end[signal]. should be hidden when user clicks on the small ▼ placed on the thin vertical bar beside number lines, then clicking again on the ▶ will show text. (like Qt Creator, Eclipse and most of other IDEs)
Update: the problem is that I can't hide lines and find a way to manage line numbering display to avoid pitfall. Any suggestion?
-
Qt Creator is open source, that means that it is open for you to study how it works...
-
I've implemented a Code Folding functionality for an IDE that I made... but it is in Python using Qt...
The code is pretty clear, and you can easily identify the Qt Classes involved.
The Editor extends from QPlainTextEdit, and you can see the implementation of the Code Folding here:Regards!
-
Thanks Diego!
Looks good... probably I'll use your code instead of writing from scratch :) -
Hi, I have modified my class where I implemented Code Folding, and now is not mixed with the Editor and works just as a Sidebar Widget where the Line Number and Folds are displayed... also now support code folding for {}.
You can take a look at:
http://code.google.com/p/ninja-ide/source/browse/ninja_ide/gui/editor/sidebar_widget.py
Regards!