#235 FoldPropsDoc in LexOthers parsing

Cosmetic
closed-fixed
Scintilla (796)
4
2005-02-18
2004-09-15
Anonymous
No

Hallo,

I'm using the setting fold.flags=17 in SciTE
and I noticed a parsing glitch in FoldPropsDoc belonging
to LexOthers.cxx.

.PROPERTIES files does have no line marked as
SC_FOLDLEVELHEADERFLAG but have every line marked
as SC_FOLDLEVELBASE+1.
This results in an unfoldable Vertical line (Fold Boxes
Experimental Feature) from the beginning to the end of
.Properties files.

also the line
if (style==2) {
headerPoint = true;
}

should be changed to

if (style==SCE_PROPS_SECTION) {
headerPoint = true;
}

I have changed:
if (atEOL) {
int lev = SC_FOLDLEVELBASE+1;
if (headerPoint)
lev = SC_FOLDLEVELBASE;

to:
if (atEOL) {
int lev = SC_FOLDLEVELBASE;
if (lineCurrent > 0) {
int levelPrevious = styler.LevelAt(lineCurrent-1);
if ( (levelPrevious & SC_FOLDLEVELHEADERFLAG &
~SC_FOLDLEVELNUMBERMASK) ==
SC_FOLDLEVELHEADERFLAG) {

lev = SC_FOLDLEVELBASE + 1;
} else {
lev = levelPrevious &
SC_FOLDLEVELNUMBERMASK;
}
}

also i removed:

int lev = headerPoint ? SC\_FOLDLEVELBASE :

SC_FOLDLEVELBASE+1;
int flagsNext = styler.LevelAt(lineCurrent) &
~SC_FOLDLEVELNUMBERMASK;
styler.SetLevel(lineCurrent, lev | flagsNext);

because it incorrectly mark the last line of a .properties
file
as SC_FOLDLEVELBASE+1

I Finally added style.props.32=fore:#FFFFFF to
others.Properties to remove the fold Boxes
(fold.flags=17) behaviour in .reg and .inf files.

It would be nice If fold.flags could be set on a per-lexer
basis or if the minumum identation
of the vertical line of Fold Boxes could be changed to
cope with files without nexted sections.

Discussion

  • Nobody/Anonymous

    Logged In: NO

    --- LexOthers.cxx Tue May 04 22:24:14 2004
    +++ New.LexOthers.cxx Thu Sep 16 09:39:15 2004
    @@ -338,13 +338,23 @@
    int style = styleNext;
    styleNext = styler.StyleAt(i + 1);
    bool atEOL = (ch == '\r' && chNext != '\n')
    || (ch == '\n');
    -
    - if (style==2) {
    + int lev= SC_FOLDLEVELBASE;
    +
    + if (style==SCE_PROPS_SECTION) {
    headerPoint = true;
    }

        if \(atEOL\) \{
    

    - int lev = SC_FOLDLEVELBASE+1;
    + if (lineCurrent > 0) {
    + int levelPrevious = styler.LevelAt(lineCurrent-1);
    +
    + if (levelPrevious & SC_FOLDLEVELHEADERFLAG) {
    + lev = SC_FOLDLEVELBASE + 1;
    + }
    + else {
    + lev = levelPrevious &
    SC_FOLDLEVELNUMBERMASK;
    + }
    + }
    if (headerPoint)
    lev =
    SC_FOLDLEVELBASE;

    @@ -365,10 +375,17 @@
    if (!isspacechar(ch))
    visibleChars++;
    }
    -
    - int lev = headerPoint ? SC_FOLDLEVELBASE :
    SC_FOLDLEVELBASE+1;
    - int flagsNext = styler.LevelAt(lineCurrent) &
    ~SC_FOLDLEVELNUMBERMASK;
    - styler.SetLevel(lineCurrent, lev | flagsNext);
    + if (lineCurrent > 0) {
    + int levelPrevious = styler.LevelAt(lineCurrent-1);
    + if (levelPrevious & SC_FOLDLEVELHEADERFLAG) {
    + lev = SC_FOLDLEVELBASE + 1;
    + }
    + else {
    + lev = levelPrevious & SC_FOLDLEVELNUMBERMASK;
    + }
    + }
    + int flagsNext = styler.LevelAt(lineCurrent);
    + styler.SetLevel(lineCurrent, lev | flagsNext &
    ~SC_FOLDLEVELNUMBERMASK);
    }

    static void ColouriseMakeLine(

     
  • Nobody/Anonymous

    Logged In: NO

    Hi,
    I'm having some problems with diff files too.

     
  • Neil Hodgson

    Neil Hodgson - 2004-09-19
    • priority: 5 --> 4
    • assigned_to: nobody --> nyamatongwe
     
  • Neil Hodgson

    Neil Hodgson - 2004-09-26

    Logged In: YES
    user_id=12579

    Box folding is not supported and will eventually be removed
    unless someone can redesign it to work in a way that is
    obvious, useful and maintainable.
    The report doesn't really explain what problem(s) are being
    fixed and how the changes address the problem(s). If the
    problem(s) are only apparent with fold boxes then I won't
    commit it.

     
  • Nobody/Anonymous

    Logged In: NO

    Hallo,
    please forgive me I'm not an experienced programmer nor I
    properly express myself writing in english.

    The problem I reported regards $(file.patterns.props) files and
    is more evident enabling foldbox.

    Disabling foldbox makes this problem only cosmetic but this
    problem is due to a parsing glitch in props lexer.

    I didn't know that foldbox was unsupported and enabling it
    provided some graphical info about folding level hierarchy.

    Take as example .properties files:
    If you disable foldbox and look at fold margin you see a long
    vertical line (usally delimiting expanded foldable blocks)
    without tree control headers (without the - sign usually
    representing the header of an expanded foldable block).

    If you open a .reg file and look at fold margin at the first line
    (where you usually see something like "Windows Registry
    Editor Version" that is not marked as SCE_PROPS_SECTION
    by the lexer) you see a vertical line without tree control
    headers that ends to the first line containing [...any text in
    square brakets...] (marked as SCE_PROPS_SECTION by the
    lexer).

    Therefore Folding does correctly work but has minor parsing
    and cosmetic glitches.

     
  • Nobody/Anonymous

    Logged In: NO

    static void FoldPropsDoc(unsigned int startPos, int length,
    int, WordList *[], Accessor &styler) {
    bool foldCompact = styler.GetPropertyInt("fold.compact",
    1) != 0;

    unsigned int endPos = startPos + length;
    int visibleChars = 0;
    int lineCurrent = styler.GetLine(startPos);

    char chNext = styler[startPos];
    int styleNext = styler.StyleAt(startPos);
    bool headerPoint = false;
    int lev;

    for (unsigned int i = startPos; i < endPos; i++) {
    char ch = chNext;
    chNext = styler[i+1];

    int style = styleNext;
    styleNext = styler.StyleAt(i + 1);
    bool atEOL = (ch == '\r' && chNext != '\n') || (ch
    == '\n');

    if (style==SCE_PROPS_SECTION) {
    headerPoint = true;
    }

    if (atEOL) {
    lev= SC_FOLDLEVELBASE;

    if (lineCurrent > 0) {
    int levelPrevious = styler.LevelAt(lineCurrent-1);

    if (levelPrevious & SC_FOLDLEVELHEADERFLAG) {
    lev = SC_FOLDLEVELBASE + 1;
    }
    else {
    lev = levelPrevious &
    SC_FOLDLEVELNUMBERMASK;
    }
    }

    if (headerPoint) {
    lev = SC_FOLDLEVELBASE;
    }
    if (visibleChars == 0 && foldCompact)
    lev |= SC_FOLDLEVELWHITEFLAG;
    if (headerPoint) {
    lev |= SC_FOLDLEVELHEADERFLAG;
    }
    if (lev != styler.LevelAt(lineCurrent)) {
    styler.SetLevel(lineCurrent, lev);
    }
    lineCurrent++;
    visibleChars = 0;
    headerPoint=false;
    }
    if (!isspacechar(ch))
    visibleChars++;
    }

    if (lineCurrent > 0) {
    int levelPrevious = styler.LevelAt(lineCurrent-1);
    if (levelPrevious & SC_FOLDLEVELHEADERFLAG) {
    lev = SC_FOLDLEVELBASE + 1;
    }
    else {
    lev = levelPrevious & SC_FOLDLEVELNUMBERMASK;
    }
    }
    else {
    lev = SC_FOLDLEVELBASE;
    }
    int flagsNext = styler.LevelAt(lineCurrent);
    styler.SetLevel(lineCurrent, lev | flagsNext &
    ~SC_FOLDLEVELNUMBERMASK);
    }

     
  • Nobody/Anonymous

    Logged In: NO

    /* this marks the first line as foldbase removing the vertical
    line in fold margin*/
    lev= SC_FOLDLEVELBASE;

    if (lineCurrent > 0) {
    int levelPrevious = (lineCurrent-1);

    /* this assigns the level of the previous line to every line
    after the 1st and correct the folding glitch in .properties
    and in .reg files; therefore .properties files have every line
    marked as foldbase while .reg files have the lines before
    bracketed section marked as foldbase and the lines after
    bracketed sections marked as foldbase + 1*/
    if (levelPrevious & SC_FOLDLEVELHEADERFLAG) {

    /* this marks any line after [...any square bracketed line..] as
    foldbase+1 creating the vertical line in fold margin */
    lev = SC_FOLDLEVELBASE + 1;
    }
    else {
    /* this duplicates foldbase or foldbase+1 */
    lev = levelPrevious & SC_FOLDLEVELNUMBERMASK;
    }
    }

    /* the rest of code handle other cases */

     
  • Neil Hodgson

    Neil Hodgson - 2004-10-03

    Logged In: YES
    user_id=12579

    Thanks, committed.

     
  • Neil Hodgson

    Neil Hodgson - 2005-02-18
    • status: open --> closed-fixed
     

Log in to post a comment.