[code] [scintillua] folder improvements

From: Tymur Gubayev <tymur.gubayev.att.gmail.com>
Date: Tue, 13 Mar 2012 00:19:09 +0100

Hi list,

 I just got some long time wanted (by me) feature of folding,
consisting of 2 things:
 1. The simple one: don't hide the very last line of fold block (I
like to see the 'end's)
 2. The one i really wanted: "fold in the middle", i.e. on "else",
"elseif", etc.
 (1+. I also realized that comment folding doesn't need such a feature)
Take a look at attached screenshot to get an idea of it in use (I
guess it's also very usefull with C-preprocessor #ifdef-#else-#end

Since the code is a bit tricky and dirty, I'll explain the algorithm a bit.
Basic idea is to add fold symbols with leveldelta = 0. If the folder
finds such symbol, it should decrease level of current line, make it
header and leave current level the same.
Sounds simple but the devil is in details.
First problem is following line: `if x then y() else z() end'. This is
single line, and it surely shouldn't affect folding... But the
algorithm found an `else', made foldlevel -1, and so on. At this
moment I started to think.
 There're basically 3 kinds of fold symbols: level increasing, level
decreasing and middle-ones. Let's call them correspondingly "+", "-"
and "0".
 Next observation: the "0" is equivalent to "-+" (order is important):
would I be able to break "else" in the middle with a newline, like
"el/se", on the "el" would be end of fold block, and on "se" - header
of the next one. It's exactly the same behaviour as of "end if" (not
what someone usually writes, but it's not forbidden too).
 Next thought: the line needs special handling if and only if amount
of "+" and "-" is equall (and, of cause, not zero)
 And the last one: we need to check, if "+" and "-" are balanced in
the line, if not - do special treating to this line.

 See possible realisation attached in lexer.patch.
(You need to add keywords to "M._foldsymbols" manually)


You are subscribed to code.at.foicica.com.
To change subscription settings, send an e-mail to code+help.at.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.at.foicica.com.
Received on Mon 12 Mar 2012 - 19:19:09 EDT

This archive was generated by hypermail 2.2.0 : Tue 13 Mar 2012 - 06:25:33 EDT