enable folding in other modes

This commit is contained in:
Fabian Jakobs 2011-12-01 15:43:33 +01:00
commit 0867c5ec40
10 changed files with 43 additions and 40 deletions

View file

@ -988,12 +988,10 @@ var EditSession = function(text, mode) {
var removedFolds = null;
if (action.indexOf("Lines") != -1) {
if (e.data.lines) {
if (action == "insertLines" && e.data.lines) {
lastRow = firstRow + (e.data.lines.length);
} else {
lastRow = firstRow;
}
if (action == "insertLines") {
lastRow = firstRow + (e.data.lines.length);
} else {
lastRow = firstRow;
}
len = e.data.lines ? e.data.lines.length : lastRow - firstRow;
} else {

View file

@ -60,6 +60,8 @@ oop.inherits(Mode, TextMode);
(function() {
this.foldingRules = "xml";
this.toggleCommentLines = function(state, doc, startRow, endRow) {
return 0;
};

View file

@ -15,7 +15,9 @@ var Mode = function() {
oop.inherits(Mode, JavaScriptMode);
(function() {
this.foldingRules = "cStyle";
this.createWorker = function(session) {
return null;
};

View file

@ -16,12 +16,13 @@ oop.inherits(Mode, TextMode);
(function() {
this.foldingRules = "cStyle";
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;

View file

@ -42,7 +42,6 @@ var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var HighlightRules = require("./json_highlight_rules").JsonHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var Range = require("../range").Range;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var Mode = function() {
@ -59,10 +58,6 @@ oop.inherits(Mode, TextMode);
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state;
if (state == "start") {
var match = line.match(/^.*[\{\(\[]\s*$/);
if (match) {

View file

@ -52,9 +52,10 @@ oop.inherits(Mode, TextMode);
(function() {
this.foldingRules = "cStyle";
this.toggleCommentLines = function(state, doc, startRow, endRow) {
var outdent = true;
var outentedRows = [];
var re = /^(\s*)#/;
for (var i=startRow; i<= endRow; i++) {
@ -86,7 +87,6 @@ oop.inherits(Mode, TextMode);
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;

View file

@ -54,9 +54,10 @@ oop.inherits(Mode, TextMode);
(function() {
this.foldingRules = "cStyle";
this.toggleCommentLines = function(state, doc, startRow, endRow) {
var outdent = true;
var outentedRows = [];
var re = /^(\s*)#/;
for (var i=startRow; i<= endRow; i++) {
@ -88,7 +89,6 @@ oop.inherits(Mode, TextMode);
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;

View file

@ -15,35 +15,36 @@ var Mode = function() {
oop.inherits(Mode, TextMode);
(function() {
this.foldingRules = "cStyle";
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state;
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;
}
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;
}
if (state == "start") {
var match = line.match(/^.*[\{\(\[]\s*$/);
if (match) {
indent += tab;
}
}
if (state == "start") {
var match = line.match(/^.*[\{\(\[]\s*$/);
if (match) {
indent += tab;
}
}
return indent;
};
return indent;
};
this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row);
};
this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row);
};
this.createWorker = function(session) {

View file

@ -15,7 +15,9 @@ var Mode = function() {
oop.inherits(Mode, JavaScriptMode);
(function() {
this.foldingRules = "cStyle";
this.createWorker = function(session) {
return null;
};

View file

@ -50,6 +50,8 @@ var Mode = function() {
oop.inherits(Mode, TextMode);
(function() {
this.foldingRules = "cStyle";
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);