Code Folding?
-
wrote on 31 May 2011, 17:12 last edited by
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?
-
wrote on 31 May 2011, 20:04 last edited by
Qt Creator is open source, that means that it is open for you to study how it works...
-
wrote on 31 May 2011, 20:27 last edited by
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!
-
wrote on 31 May 2011, 20:59 last edited by
Thanks Diego!
Looks good... probably I'll use your code instead of writing from scratch :) -
wrote on 1 Jun 2011, 14:12 last edited by
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!
1/5