PluginProbe ʕ •ᴥ•ʔ
SiteOrigin CSS / 1.1
SiteOrigin CSS v1.1
1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.10 1.5.11 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0
so-css / lib / codemirror / addon / fold / indent-fold.js
so-css / lib / codemirror / addon / fold Last commit date
brace-fold.js 11 years ago brace-fold.min.js 10 years ago comment-fold.js 10 years ago comment-fold.min.js 10 years ago foldcode.js 11 years ago foldcode.min.js 10 years ago foldgutter.css 11 years ago foldgutter.js 11 years ago foldgutter.min.js 10 years ago indent-fold.js 11 years ago indent-fold.min.js 10 years ago markdown-fold.js 11 years ago markdown-fold.min.js 10 years ago xml-fold.js 11 years ago xml-fold.min.js 10 years ago
indent-fold.js
45 lines
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
3
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
10 mod(CodeMirror);
11 })(function(CodeMirror) {
12 "use strict";
13
14 CodeMirror.registerHelper("fold", "indent", function(cm, start) {
15 var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
16 if (!/\S/.test(firstLine)) return;
17 var getIndent = function(line) {
18 return CodeMirror.countColumn(line, null, tabSize);
19 };
20 var myIndent = getIndent(firstLine);
21 var lastLineInFold = null;
22 // Go through lines until we find a line that definitely doesn't belong in
23 // the block we're folding, or to the end.
24 for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) {
25 var curLine = cm.getLine(i);
26 var curIndent = getIndent(curLine);
27 if (curIndent > myIndent) {
28 // Lines with a greater indent are considered part of the block.
29 lastLineInFold = i;
30 } else if (!/\S/.test(curLine)) {
31 // Empty lines might be breaks within the block we're trying to fold.
32 } else {
33 // A non-empty line at an indent equal to or less than ours marks the
34 // start of another block.
35 break;
36 }
37 }
38 if (lastLineInFold) return {
39 from: CodeMirror.Pos(start.line, firstLine.length),
40 to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length)
41 };
42 });
43
44 });
45