Simple Pattern-Based Folding in Lexers

From: mitchell <c....at.caladbolg.net>
Date: Sun, 15 May 2011 13:45:19 -0400 (EDT)

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:

_foldsymbols = {
   _patterns = { '%l+', '[%({%)}%[%]]' },
   keyword = {
     ['if'] = 1, ['do'] = 1, ['function'] = 1, ['repeat'] = 1,
     ['end'] = -1, ['until'] = -1
   },
   operator = { ['('] = 1, ['{'] = 1, [')'] = -1, ['}'] = -1 },
   comment = { ['['] = 1, [']'] = -1 },
   longstring = { ['['] = 1, [']'] = -1 }
}

Note that this is an experimental feature subject to change. Comments are
welcome.

mitchell
Received on Sun 15 May 2011 - 13:45:19 EDT

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