enable folding in other modes
This commit is contained in:
parent
71d5f359fb
commit
0867c5ec40
10 changed files with 43 additions and 40 deletions
|
|
@ -988,12 +988,10 @@ var EditSession = function(text, mode) {
|
||||||
var removedFolds = null;
|
var removedFolds = null;
|
||||||
|
|
||||||
if (action.indexOf("Lines") != -1) {
|
if (action.indexOf("Lines") != -1) {
|
||||||
if (e.data.lines) {
|
if (action == "insertLines") {
|
||||||
if (action == "insertLines" && e.data.lines) {
|
lastRow = firstRow + (e.data.lines.length);
|
||||||
lastRow = firstRow + (e.data.lines.length);
|
} else {
|
||||||
} else {
|
lastRow = firstRow;
|
||||||
lastRow = firstRow;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
len = e.data.lines ? e.data.lines.length : lastRow - firstRow;
|
len = e.data.lines ? e.data.lines.length : lastRow - firstRow;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.foldingRules = "xml";
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, JavaScriptMode);
|
oop.inherits(Mode, JavaScriptMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.foldingRules = "cStyle";
|
||||||
|
|
||||||
this.createWorker = function(session) {
|
this.createWorker = function(session) {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,13 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.foldingRules = "cStyle";
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
||||||
var tokens = tokenizedLine.tokens;
|
var tokens = tokenizedLine.tokens;
|
||||||
var endState = tokenizedLine.state;
|
|
||||||
|
|
||||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||||
return indent;
|
return indent;
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ var TextMode = require("./text").Mode;
|
||||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
var HighlightRules = require("./json_highlight_rules").JsonHighlightRules;
|
var HighlightRules = require("./json_highlight_rules").JsonHighlightRules;
|
||||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||||
var Range = require("../range").Range;
|
|
||||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
|
|
@ -59,10 +58,6 @@ oop.inherits(Mode, TextMode);
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
|
||||||
var tokens = tokenizedLine.tokens;
|
|
||||||
var endState = tokenizedLine.state;
|
|
||||||
|
|
||||||
if (state == "start") {
|
if (state == "start") {
|
||||||
var match = line.match(/^.*[\{\(\[]\s*$/);
|
var match = line.match(/^.*[\{\(\[]\s*$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,10 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.foldingRules = "cStyle";
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
||||||
var outdent = true;
|
var outdent = true;
|
||||||
var outentedRows = [];
|
|
||||||
var re = /^(\s*)#/;
|
var re = /^(\s*)#/;
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
for (var i=startRow; i<= endRow; i++) {
|
||||||
|
|
@ -86,7 +87,6 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
||||||
var tokens = tokenizedLine.tokens;
|
var tokens = tokenizedLine.tokens;
|
||||||
var endState = tokenizedLine.state;
|
|
||||||
|
|
||||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||||
return indent;
|
return indent;
|
||||||
|
|
|
||||||
|
|
@ -54,9 +54,10 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.foldingRules = "cStyle";
|
||||||
|
|
||||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
||||||
var outdent = true;
|
var outdent = true;
|
||||||
var outentedRows = [];
|
|
||||||
var re = /^(\s*)#/;
|
var re = /^(\s*)#/;
|
||||||
|
|
||||||
for (var i=startRow; i<= endRow; i++) {
|
for (var i=startRow; i<= endRow; i++) {
|
||||||
|
|
@ -88,7 +89,6 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
||||||
var tokens = tokenizedLine.tokens;
|
var tokens = tokenizedLine.tokens;
|
||||||
var endState = tokenizedLine.state;
|
|
||||||
|
|
||||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||||
return indent;
|
return indent;
|
||||||
|
|
|
||||||
|
|
@ -15,35 +15,36 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.foldingRules = "cStyle";
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
||||||
var tokens = tokenizedLine.tokens;
|
var tokens = tokenizedLine.tokens;
|
||||||
var endState = tokenizedLine.state;
|
|
||||||
|
|
||||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||||
return indent;
|
return indent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == "start") {
|
if (state == "start") {
|
||||||
var match = line.match(/^.*[\{\(\[]\s*$/);
|
var match = line.match(/^.*[\{\(\[]\s*$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
indent += tab;
|
indent += tab;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return indent;
|
return indent;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.checkOutdent = function(state, line, input) {
|
this.checkOutdent = function(state, line, input) {
|
||||||
return this.$outdent.checkOutdent(line, input);
|
return this.$outdent.checkOutdent(line, input);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.autoOutdent = function(state, doc, row) {
|
this.autoOutdent = function(state, doc, row) {
|
||||||
this.$outdent.autoOutdent(doc, row);
|
this.$outdent.autoOutdent(doc, row);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
this.createWorker = function(session) {
|
this.createWorker = function(session) {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, JavaScriptMode);
|
oop.inherits(Mode, JavaScriptMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.foldingRules = "cStyle";
|
||||||
|
|
||||||
this.createWorker = function(session) {
|
this.createWorker = function(session) {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,8 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.foldingRules = "cStyle";
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var indent = this.$getIndent(line);
|
var indent = this.$getIndent(line);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue