aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/LPegLexer.html45
-rw-r--r--lexers/LexLPeg.cxx21
-rw-r--r--lexlua/lexer.lua25
3 files changed, 90 insertions, 1 deletions
diff --git a/doc/LPegLexer.html b/doc/LPegLexer.html
index 22546537b..a9ecbbf72 100644
--- a/doc/LPegLexer.html
+++ b/doc/LPegLexer.html
@@ -1570,6 +1570,24 @@ operator 30
<p>A pattern that matches a floating point number.</p>
+ <p><a id="lexer.fold_by_indentation"></a></p>
+
+ <h3><code>lexer.fold_by_indentation</code> (boolean)</h3>
+
+ <p>Whether or not to fold based on indentation level if a lexer does not have
+ a folder.
+ Some lexers automatically enable this option. It is disabled by default.
+ This is an alias for <code>lexer.property['fold.by.indentation'] = '1|0'</code>.</p>
+
+ <p><a id="lexer.fold_compact"></a></p>
+
+ <h3><code>lexer.fold_compact</code> (boolean)</h3>
+
+ <p>Whether or not blank lines after an ending fold point are included in that
+ fold.
+ This option is disabled by default.
+ This is an alias for <code>lexer.property['fold.compact'] = '1|0'</code>.</p>
+
<p><a id="lexer.fold_level"></a></p>
<h3><code>lexer.fold_level</code> (table, Read-only)</h3>
@@ -1588,6 +1606,33 @@ operator 30
</ul>
+ <p><a id="lexer.fold_line_comments"></a></p>
+
+ <h3><code>lexer.fold_line_comments</code> (boolean)</h3>
+
+ <p>Whether or not to fold multiple, consecutive line comments and only show
+ the top-level comment.
+ This option is disabled by default.
+ This is an alias for <code>lexer.property['fold.line.comments'] = '1|0'</code>.</p>
+
+ <p><a id="lexer.fold_on_zero_sum_lines"></a></p>
+
+ <h3><code>lexer.fold_on_zero_sum_lines</code> (boolean)</h3>
+
+ <p>Whether or not to mark as a fold point lines that contain both an ending
+ and starting fold point. For example, <code>} else {</code> would be marked as a fold
+ point.
+ This option is disabled by default.
+ This is an alias for <code>lexer.property['fold.on.zero.sum.lines'] = '1|0'</code>.</p>
+
+ <p><a id="lexer.folding"></a></p>
+
+ <h3><code>lexer.folding</code> (boolean)</h3>
+
+ <p>Whether or not folding is enabled.
+ This option is disabled by default.
+ This is an alias for <code>lexer.property['fold'] = '1|0'</code>.</p>
+
<p><a id="lexer.graph"></a></p>
<h3><code>lexer.graph</code> (pattern)</h3>
diff --git a/lexers/LexLPeg.cxx b/lexers/LexLPeg.cxx
index d4f21f25c..cbd37eefd 100644
--- a/lexers/LexLPeg.cxx
+++ b/lexers/LexLPeg.cxx
@@ -327,6 +327,13 @@ static int lexer_index(lua_State *L) {
luaL_argcheck(
L, lua_getfield(L, -1, "_BUFFER"), 2, "must be lexing or folding");
lua_pushcclosure(L, line_from_position, 1);
+ } else if (strncmp(key, "fold", 4) == 0) {
+ // Alias lexer.fold* to lexer.property['fold*'].
+ if (strcmp(key, "folding") == 0) key = "fold"; // lexer.fold() exists
+ lua_getfield(L, LUA_REGISTRYINDEX, "sci_lexer_lpeg");
+ LexerLPeg *lexer = reinterpret_cast<LexerLPeg *>(lua_touserdata(L, -1));
+ const char *value = lexer->PropertyGet(luaL_gsub(L, key, "_", "."));
+ lua_pushboolean(L, strcmp(value, "1") == 0);
} else lua_rawget(L, 1);
return 1;
}
@@ -339,7 +346,19 @@ static int lexer_newindex(lua_State *L) {
strcmp(key, "property") != 0 && strcmp(key, "property_int") != 0 &&
strcmp(key, "style_at") != 0 && strcmp(key, "line_state") != 0 &&
strcmp(key, "line_from_position") != 0, 3, "read-only property");
- return (lua_rawset(L, 1), 0);
+ if (strncmp(key, "fold", 4) == 0 && strcmp(key, "fold_level") != 0) {
+ // Alias lexer.fold* to lexer.property['fold*'].
+ if (strcmp(key, "folding") == 0) key = "fold"; // lexer.fold() exists
+ key = luaL_gsub(L, key, "_", ".");
+ lua_getfield(L, LUA_REGISTRYINDEX, "sci_lexer_lpeg");
+ LexerLPeg *lexer = reinterpret_cast<LexerLPeg *>(lua_touserdata(L, -1));
+ if (lua_toboolean(L, 3))
+ lexer->PropertySet(
+ key, (!lua_isnumber(L, 3) || lua_tonumber(L, 3) == 1) ? "1" : "0");
+ else
+ lexer->PropertySet(key, "0");
+ } else lua_rawset(L, 1);
+ return 0;
}
/**
diff --git a/lexlua/lexer.lua b/lexlua/lexer.lua
index 72952c774..f35976df9 100644
--- a/lexlua/lexer.lua
+++ b/lexlua/lexer.lua
@@ -846,6 +846,31 @@ local M = {}
-- found.
-- @field style_at (table, Read-only)
-- Table of style names at positions in the buffer starting from 1.
+-- @field folding (boolean)
+-- Whether or not folding is enabled.
+-- This option is disabled by default.
+-- This is an alias for `lexer.property['fold'] = '1|0'`.
+-- @field fold_on_zero_sum_lines (boolean)
+-- Whether or not to mark as a fold point lines that contain both an ending
+-- and starting fold point. For example, `} else {` would be marked as a fold
+-- point.
+-- This option is disabled by default.
+-- This is an alias for `lexer.property['fold.on.zero.sum.lines'] = '1|0'`.
+-- @field fold_compact (boolean)
+-- Whether or not blank lines after an ending fold point are included in that
+-- fold.
+-- This option is disabled by default.
+-- This is an alias for `lexer.property['fold.compact'] = '1|0'`.
+-- @field fold_by_indentation (boolean)
+-- Whether or not to fold based on indentation level if a lexer does not have
+-- a folder.
+-- Some lexers automatically enable this option. It is disabled by default.
+-- This is an alias for `lexer.property['fold.by.indentation'] = '1|0'`.
+-- @field fold_line_comments (boolean)
+-- Whether or not to fold multiple, consecutive line comments and only show
+-- the top-level comment.
+-- This option is disabled by default.
+-- This is an alias for `lexer.property['fold.line.comments'] = '1|0'`.
module('lexer')]=]
if not require then