custom folding with stc.StyledTextCtrl

I'd like to implement some very simple folding for a stc.StyledTextCtrl. I assume the folding is based on the lexer and I'm using the STC_LEX_SQL lexer, which I doubt has any folding defined, but I don't know where to look.

Markers would look like this:

- -- First Query (unfolded)
   SELECT * FROM tablename1
   WHERE fieldname1 = 'text1'

   break

+ Second Query (folded)

- -- Third Query (unfolded)
   SELECT * FROM table2
   WHERE fieldname2 = 'text2'

* '-- and text' is an SQL comment
* 'break' indicates query separation.
* if a comment is given on the first line, it is shown when query is folded.

So the fold logic would look like this:

is_fold_point = False
if position == first_line_of_text or position == first_line_after_break:
     is_fold_point = True

Randall

Randall Smith wrote:

I'd like to implement some very simple folding for a stc.StyledTextCtrl. I assume the folding is based on the lexer and I'm using the STC_LEX_SQL lexer, which I doubt has any folding defined, but I don't know where to look.

Looks like it does have some foldling abilities built-in to the lexer. You can see the lexer implementation here: http://svn.wxwidgets.org/viewvc/wx/wxWidgets/branches/WX_2_8_BRANCH/contrib/src/stc/scintilla/src/LexSQL.cxx?revision=44296&view=markup

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!