Stefan Küng:
> But I would like a new style that's changing the contracted line itself, something like this:
>
> if ((!expanded && (model.foldFlags & SC_FOLDFLAG_RECTANGLE_OVER_CONTRACTED))) {
> PRectangle rcFoldLine = rcLine;
> surface->AlphaRectangle(rcFoldLine, 1, vsDraw.styles[STYLE_DEFAULT].fore, 50, vsDraw.styles[STYLE_DEFAULT].fore, 255, 0);
> }
This looks like: http://www.scintilla.org/BlockHeader.png
> Of course, this could maybe be extended so that the line text has "..." appended, indicating that the line is folded.
The […] blobs that some editors use are more complex: they may indicate the type of the fold [ /* … */ ] or [<table>…</table>] and may support navigation and selection of the block. A good implementation here would be useful but I don’t think a minimal one is worth including.
However, just showing "[...]" on the folder header would be good enough for me: it shows that there's something hidden more clearly than just a line or even the block header. It would be a small but useful indicator that this is a fold.
I noticed that SCI_MARGINSETTEXT and SCI_ANNOTATIONSETTEXT directly takes the char * from outside and makes no copy. Should I follow that practice?
So should we assume that char* passed in is allocated to the heap and would not be deallocated?
DrawFoldDisplayText
void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
int line, int lineVisible, int xStart, PRectangle rcLine, int subLine, DrawPhase phase)
//Case 1:
//Before folding: (caret inside folding text / selection part of folding text)
....
{
.... |
}
//After folding: (caret becomes in front of folding parent)
....
|{
//Case 2:
//Before folding: (selection includes the whole folding text)
....
{
....
}
...
//After folding: (selection still includes the whole folding part)
....
{
...
SelectionRange Editor::FoldExpandIfModified(SelectionRange range)
Some[<FoldBlob>...</FoldBlob>]Text // fold parent line
// Example
// Text Before Folding
/**
// Text After Folding
[Here is the BLOB...]
// Current caret problem: line max position
[He|re is the BLOB...] //Problem: This is the last caret position because the original first line string(/**) is 3 char only
// Expected caret behaviour: line max position
[Here is the BLOB...]|
// Most Expected caret behaviour:
//Before Typing
|[Here is the BLOB...]
//Now Type 1 right arrow...
[Here is the BLOB...]|
//Now Type 1 left arrow again...
|[Here is the BLOB...]
ScintillaTest is a shell to experiment with and doesn’t always have everything properly implemented.
Since lexer styles restart at 40, STYLE_LASTPREDEFINED can not be changed.
# Styles in range 32..38 are predefined for parts of the UI and are not used as normal styles.
# Style 39 is for future use.
Scintilla.h is automatically generated from Scintilla.iface so API changes should go there first.
DrawFoldDisplayText has unused arguments
Checking character by character in the whole hidden region, which may be thousands of lines long is inefficient.
For wrapped text, the contraction tag is drawn on each subline.
For visible line ends, the tag is drawn over the line end.
Wonson:
There is no style attribute for outline rectangle so, if this is to be drawn, it should be separate parameter or be determined algorithmically. It could be the text colour, a neutral mid-grey, or white|black determined as the most visible by being furthest from the background of either STYLE_FOLDDISPLAYTEXT or STYLE_DEFAULT ((r+g+b) > 3*0x7f) ? black : white.
> Folding text border is removed, I am working on a set of indicators like interfaces, which allow application set the folding box style.
OK, but don’t define too many styles as it is difficult to predict what will be wanted.
* fix fold text box width with visual space
* draw the box in drawIndicatorsFore phase
* remove test `stFoldText.text && ValidStyledText()`
* use `strlen()` to calculate fold text length
* use `WidthText()` to calculate fold text width