[PyKDE] eric3, qscintilla and code folding

Baz Walter bazwal at ftml.net
Wed Oct 19 18:32:32 BST 2005


On Tuesday 18 Oct 2005 14:36, Brad Ralph wrote:
>
> 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.
>

I thought it might be possible to get a bit closer to what you want if 
QScintilla had a "foldChildren" method, so I wrote one. You could use this to 
add a "Toggle Child Folds" and "Collapse Child Folds" to eric3's View Menu. 
If you also created keyboard shortcuts for these new menu items, it might 
make quite a nice improvement to the user interface.

This function should be added to eric3's QScintilla.Editor class:

def foldChildren(self, line, toggle=True):
	if toggle:
		btnstate = QextScintilla.SCMOD_CTRL
	else:
		btnstate = QextScintilla.SCMOD_SHIFT
	linepos = self.SendScintilla(
				QextScintilla.SCI_POSITIONFROMLINE, line, 0)
	self.emit(
		SIGNAL('SCN_MARGINCLICK(int,int,int)'),
		(linepos, btnstate, 2))

(A ctrl+click toggles all the child-folds of a foldable line.
 A shift+click expands all the child-folds of a foldable line).


HTH

-- 
Baz Walter




More information about the PyQt mailing list