From 0867c5ec409c2d108cfaf6d423a238f4d55555c6 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Thu, 1 Dec 2011 15:43:33 +0100 Subject: [PATCH] enable folding in other modes --- lib/ace/edit_session.js | 10 ++++----- lib/ace/mode/coldfusion.js | 2 ++ lib/ace/mode/groovy.js | 4 +++- lib/ace/mode/haxe.js | 3 ++- lib/ace/mode/json.js | 5 ----- lib/ace/mode/perl.js | 4 ++-- lib/ace/mode/php.js | 4 ++-- lib/ace/mode/powershell.js | 45 +++++++++++++++++++------------------- lib/ace/mode/scala.js | 4 +++- lib/ace/mode/scss.js | 2 ++ 10 files changed, 43 insertions(+), 40 deletions(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 378713be..658174e6 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -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 { diff --git a/lib/ace/mode/coldfusion.js b/lib/ace/mode/coldfusion.js index b33f3686..e724bacc 100644 --- a/lib/ace/mode/coldfusion.js +++ b/lib/ace/mode/coldfusion.js @@ -60,6 +60,8 @@ oop.inherits(Mode, TextMode); (function() { + this.foldingRules = "xml"; + this.toggleCommentLines = function(state, doc, startRow, endRow) { return 0; }; diff --git a/lib/ace/mode/groovy.js b/lib/ace/mode/groovy.js index 18f5bb61..f373e1e0 100644 --- a/lib/ace/mode/groovy.js +++ b/lib/ace/mode/groovy.js @@ -15,7 +15,9 @@ var Mode = function() { oop.inherits(Mode, JavaScriptMode); (function() { - + + this.foldingRules = "cStyle"; + this.createWorker = function(session) { return null; }; diff --git a/lib/ace/mode/haxe.js b/lib/ace/mode/haxe.js index 5172002b..f39befa7 100644 --- a/lib/ace/mode/haxe.js +++ b/lib/ace/mode/haxe.js @@ -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; diff --git a/lib/ace/mode/json.js b/lib/ace/mode/json.js index d725a22f..cb86f34b 100644 --- a/lib/ace/mode/json.js +++ b/lib/ace/mode/json.js @@ -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) { diff --git a/lib/ace/mode/perl.js b/lib/ace/mode/perl.js index 0ce562b5..e04507bd 100644 --- a/lib/ace/mode/perl.js +++ b/lib/ace/mode/perl.js @@ -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; diff --git a/lib/ace/mode/php.js b/lib/ace/mode/php.js index 1dc23e0f..a875c355 100644 --- a/lib/ace/mode/php.js +++ b/lib/ace/mode/php.js @@ -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; diff --git a/lib/ace/mode/powershell.js b/lib/ace/mode/powershell.js index 1b9e362e..4f3ceb76 100644 --- a/lib/ace/mode/powershell.js +++ b/lib/ace/mode/powershell.js @@ -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) { diff --git a/lib/ace/mode/scala.js b/lib/ace/mode/scala.js index 58448099..5166308e 100644 --- a/lib/ace/mode/scala.js +++ b/lib/ace/mode/scala.js @@ -15,7 +15,9 @@ var Mode = function() { oop.inherits(Mode, JavaScriptMode); (function() { - + + this.foldingRules = "cStyle"; + this.createWorker = function(session) { return null; }; diff --git a/lib/ace/mode/scss.js b/lib/ace/mode/scss.js index 88c7db49..ba2d8292 100644 --- a/lib/ace/mode/scss.js +++ b/lib/ace/mode/scss.js @@ -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);