Tony and Bert,

Thanks for your responses.  Guess I need to keep plugging along.  Some 
followups below.

On Thursday 03 April 2008 03:22 pm, Tony Balinski wrote:
> Quoting Randy Kramer <[EMAIL PROTECTED]>:
> > One way to mark currently folded text in the textBuf could be using the
> > 32-bit Style mask which, based on this line of code in textDisp.c:
> >
> >     textBuffer *styleBuf = textD->styleBuffer;
> >
> > ..., is like a parallel textBuf(fer) storing the style information for 
each
> > character of text in the textBuf?
> 
> That's right: each byte matches a style index, the bottom 8bits of the style
> mask given below. Beware though: if you haven't applied highlighting, you
> get no style buffer. 

Interesting, but maybe not a problem, because I sort of anticipate folding and 
highlighting being somewhat related.  I'm thinking that the Syntax 
Highlighting --> Recognition Patterns screen (or something very similar) 
would be used to set patterns to recognize (automatic) folding regions (i.e., 
folding regions based on syntax).   (Maybe this thinking is partially 
influence by kate, which sets both syntax highlighting and folding patterns 
in the same .xml file.)

> The style index gives you a style record, saying 
> something like "Comment style", foreground=grey, background=<none>, bold 
font,
> italic font. That's used to draw the corresponding matching text.
> 
> > ... I would consider using an additional bit (or 2,
> > more on that later) to add a "hidden for folding" flag to the 32-Bit Style
> > mask:
> >
> > > /* If you use both 32-Bit Style mask layout:
> > >    Bits
> > > +----------------+----------------+----------------+----------------+
> > > |1F1E1D1C1B1A1918|1716151413121110| F E D C B A 9 8| 7 6 5 4 3 2 1 0|
> > > |3130292827262524|2322212019181716|151413121110 9 8| 7 6 5 4 3 2 1 0|
> > > +----------------+----------------+----------------+----------------+
> > > |             r r| r r r r b b b b| b b b b H 1 2 F| s s s s s s s s|
> > > +----------------+----------------+----------------+----------------+
> >
> > The text display widget would then be modified so that if text was marked
> > as "hidden for folding", it would not be displayed.
> 
> No: the style buffer doesn't give this whole style value. It's built on the
> fly (see styleOfPos()) from the style buffer entry of a position, along with
> other rendering factors: whether this is the end of line (F for "fill to the
> right"), primary/secondary selection (1, 2), bracket-matching highlighting
> (H), character-value-based backlighting (b) and rangeset index. All this is
> broken down again (in drawString()) how best to draw the next segment of 
text.
> 
> For folding, though, you're not going to draw normal buffer text (you may 
want
> to draw a placeholder, for which a bit in the style mask might well be
> appropriate). Note (in redisplayLine()) that drawString() is called with a
> length of similarly-styled text. This would be, I reckon, where a look at 
the
> folded ranges, would tell you where a fold-marker (or nothing!) should be
> drawn. In other words, a folded fold is not a style; it just never gets
> displayed. In this way you don't have to scan every character of folded text
> just to find where visibility gets turned on again. You must, however, 
account
> for missing character positions and line numbers, and manage column 
positions
> and mouse-position-to-text-position mapping given these jumps in the 
position
> sequence.

Yes, that's one of the parts I see as the hard part--at some point I'll write 
a separate post about this.

Just for the sake of learning, I found the following near the bottom of 
textDisp.c--at some point it must be converted to an 8-bit code--can you tell 
me where (or how) that happens.  (I'm after the how, but I'm hoping if you 
tell me where I can read the code and figure out the how.)

/* The format of the class string s is:
          low[-high]{,low[-high]}:color{;low-high{,low[-high]}:color}
      eg
          32-255:#f0f0f0;1-31,127:red;128-159:orange;9-13:#e5e5e5
   where low and high represent a character range between ordinal
   ASCII values. Using strtol() allows automatic octal, dec and hex
   reading of low and high. The example format sets backgrounds as follows:
          char   1 - 8    colored red     (control characters)
          char   9 - 13   colored #e5e5e5 (isspace() control characters)
          char  14 - 31   colored red     (control characters)
          char  32 - 126  colored #f0f0f0
          char 127        colored red     (delete character)
          char 128 - 159  colored orange  ("shifted" control characters)
          char 160 - 255  colored #f0f0f0
   Notice that some of the later ranges overwrite the class values defined
   for earlier ones (eg the first clause, 32-255:#f0f0f0 sets the DEL
   character background color to #f0f0f0; it is then set to red by the
   clause 1-31,127:red). */ 

Randy Kramer

> > Another thing that the styleBuf would then be used for is, generally
> > speaking, navigation.  For example, when we needed to move the cursor, for
> > example, down one line, the navigation routines would be modified so that
> > they checked the styleBuf and ignored all characters that were flagged
> > "hidden for folding".
> 
> Same argument.
-- 
NEdit Develop mailing list - [email protected]
http://www.nedit.org/mailman/listinfo/develop

Reply via email to