Re: [textadept] Simple Pattern-Based Folding in Lexers

From: Robert <ro....at.web.de>
Date: Mon, 16 May 2011 19:24:34 +0200

On Mon, May 16, 2011 at 3:48 PM, mitchell <c....at.caladbolg.net> wrote:
> Robert,
>
> On Mon, 16 May 2011, Robert wrote:
>
>> Hi Mitchell,
>>
>> On Sun, May 15, 2011 at 7:49 PM, mitchell <c....at.caladbolg.net> wrote:
>>>
>>> On Sun, 15 May 2011, mitchell wrote:
>>>
>>>> Hi everyone,
>>>>
>>>> I have commited code to Scintillua (http://scintillua.googlecode.com)
>>>> that
>>>> allows for simple pattern-based code folding to be defined in lexers
>>>> instead
>>>> of full _fold() functions. I have implemented this folding for the lua
>>>> and
>>>> cpp lexers for reference. Lexer authors, please see the appropriate
>>>> documentation in lexer.lua (search for "Simple Code Folding"). Here is a
>>>> snippet for folding Lua:
>>>
>>> I forgot to mention that LexLPeg.cxx was also changed so in order to
>>> test,
>>> you will have to recompile ta.
>>>
>>> mitchell
>>> [...]
>>>>
>>>> Note that this is an experimental feature subject to change. Comments
>>>> are
>>>> welcome.
>>>>
>>>> mitchell
>>
>> I found an issue here:
>> line 104 in lexer.lua
>> --   `:` to `@`, `[` to `'`, `{` to `~`).
>> starts a marker.
>
> In my defense SciTE has this bug too since I based my folding on its
> folding.
>
Yeah, it's probably quite an edge case.

>> I tried the example code for folding by indentation with the Python
>> lexer (this seems to be exactly what I meant with "generic
>> translation" - couldn't something like this be a fallback?)
>
> I'm confused. fold.by.indentation is on unless you explicitly set it off;
> therefore it works fine with python out of the box, no?
>
Sorry for the bad report. Folding by indentation works with Python. To
get the lines in the
folding margin (with the alaran-dark theme) I thought I could use the
folding code
from lexer.lua I copied the _fold function into the Python lexer.

>> With Python I get:
>> textadept/lexers/python.lua:134: attempt to index global 'text' (a nil
>> value).
>> Lua Error: Table of folds expected from lexer.fold.
>
> That's because I'm using a non-existant variable. Change 'text' to 'input'.
>
I should probably have been able to figure that out :-)
There is no error now, but the lines spanning a fold in the margin are
still not drawn.

>> I just copied over the example from the docs. Dmd and the earlier Lua
>> version with folding seem to work fine.
>>
>> Another issue:
>> when I switch the lexer and back to the Lua lexer, the lines aren't drawn.
>
> What line? I'm having trouble reproducing.
>
I switch the lexer (e.g. to Io) and then back to Lua. After the switch
the lines in the
folding margin aren't drawn.

Robert

> mitchell
>
> --
> You received this message because you are subscribed to the Google Groups
> "textadept" group.
> To post to this group, send email to textadept.at.googlegroups.com.
> To unsubscribe from this group, send email to
> textadept+unsubscribe.at.googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/textadept?hl=en.
>
>
Received on Mon 16 May 2011 - 13:24:34 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:07:21 EST