[PyKDE] eric3, qscintilla and code folding

Baz Walter bazwal at ftml.net
Tue Oct 18 23:38:45 BST 2005


On Tuesday 18 Oct 2005 14:36, Brad Ralph wrote:
> Hi Baz,
>
> Thanks for your suggestion it was very helpful.  I tried Ctrl-clicking the
> class fold marker and as you suggest it colapses all of the child folds.  I
> also tried the Ctrl and Shift but this is the same as the toggle all folds
> menu option (class gets folded but the children don't).
>
> The problem is I seem to be too fussy.  When you fold all of the children
> (Ctrl - Click) it becomes a bit annoying to have to unfold the if
> statements and triple quoted strings of any method that you are working in.
>  I know that this can be turned off in the settings (so that strings are
> not folded) but then we loose the option to do so if you want to on a case
> by case basis.
>
> The whole idea of my little function is to only fold lines with 'def'
> statements.  This would be like having my cake and getting to eat it.
>
> The other reason I was playing with code is to become more familiar with
> the eric3 way of writing PyQt programs.  eric3 is probably the biggest and
> most functional PyQt program that I have seen to date so I figure there is
> a lot that I can learn from it.
>

At present, QScintilla doesn't provide the high-level functions you'd need to 
get your idea to work *reliably*. For finer control of folding, you'd need to 
use some methods of the QScintillaBase class to access the lower-level api of 
the Scintilla editing control. Even then, having had a look at the Scintilla 
documentation, I'm not sure it would be possible to do *exactly* what you're 
trying to do. The fold-level of a line is usually set by a lexer, so there 
may be no direct way to determine what kind of line is being folded (you'd 
have to look at the source code to see how the various flags were set). All 
in all, I'd say that this was a fairly tricky problem for a relative newcomer 
to pyqt to take on. And, ironically, if you managed to crack it, I reckon 
your code would probably end up looking more like c++ than pyqt ;-)

-- 
Baz Walter




More information about the PyQt mailing list