Re: [code] [textadept] highlighting dates and hours

From: Mitchell <m.att.foicica.com>
Date: Tue, 4 Apr 2017 13:36:56 -0400 (EDT)

Hi,

On Tue, 4 Apr 2017, Pascal wrote:

> hi Mitchell,
>
> I chose to make several simple loops (by slightly rearranging my regular
> expressions) and it works perfectly, well, so again, thank you for your
> advice.
>
> can you help me on two other points?
>
> firstly, I use the function buffer.fold_all with the action
> buffer.FOLDACTION_CONTRACT : it works, but only on the first level.
>
> events.connect(events.FILE_OPENED,
> function()
> ...
> buffer.fold_all(buffer.FOLDACTION_CONTRACT)
> buffer.read_only = true
> end
> )
>
> for example :
>
> <level1>
> blabla
> <level2>
> blabla
> </level2>
> </level1>
> <level1>
> blabla
> <level2>
> blabla
> </level2>
> </level1>
>
> give the good display :
>
> + <level1>
> + <level1>
>
> but, if I unfold the first folding, the second level is already unfolded :
>
> <level1>
> blabla
> <level2>
> blabla
> </level2>
> </level1>
> + <level1>
>
> and I would like :
>
> <level1>
> blabla
> + <level2>
> </level1>
> + <level1>
>
> is it possible ?

Yes, you should iterate over all lines and call `buffer:fold_children()`
instead. Something like this may work:

   for i = 0, buffer.line_count - 1 do
     if buffer.fold_level[i] >= buffer.FOLDLEVELHEADERFLAG then
       buffer:fold_children(i, buffer.FOLDACTION_CONTRACT)
     end
   end

Then, each fold you expand will only expand that level.

> and secondly, is it possible to disable syntax highlighting, especially on
> xml language, without losing folding ?

No, this is not possible.

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Tue 04 Apr 2017 - 13:36:56 EDT

This archive was generated by hypermail 2.2.0 : Wed 05 Apr 2017 - 06:37:28 EDT