add folding fr yaml and tcl

This commit is contained in:
nightwing 2012-08-26 01:12:48 +04:00
commit 96f46cf2f0
3 changed files with 24 additions and 25 deletions

View file

@ -19,37 +19,32 @@ oop.inherits(Mode, TextMode);
(function() { (function() {
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;
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) {
return null;
}; };
}).call(Mode.prototype); }).call(Mode.prototype);

View file

@ -42,6 +42,7 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer; var Tokenizer = require("../tokenizer").Tokenizer;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var TclHighlightRules = require("./tcl_highlight_rules").TclHighlightRules; var TclHighlightRules = require("./tcl_highlight_rules").TclHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var Range = require("../range").Range; var Range = require("../range").Range;
@ -49,6 +50,7 @@ var Range = require("../range").Range;
var Mode = function() { var Mode = function() {
this.$tokenizer = new Tokenizer(new TclHighlightRules().getRules()); this.$tokenizer = new Tokenizer(new TclHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent(); this.$outdent = new MatchingBraceOutdent();
this.foldingRules = new CStyleFoldMode();
}; };
oop.inherits(Mode, TextMode); oop.inherits(Mode, TextMode);

View file

@ -26,10 +26,12 @@ var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer; var Tokenizer = require("../tokenizer").Tokenizer;
var YamlHighlightRules = require("./yaml_highlight_rules").YamlHighlightRules; var YamlHighlightRules = require("./yaml_highlight_rules").YamlHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var FoldMode = require("./folding/coffee").FoldMode;
var Mode = function() { var Mode = function() {
this.$tokenizer = new Tokenizer(new YamlHighlightRules().getRules()); this.$tokenizer = new Tokenizer(new YamlHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent(); this.$outdent = new MatchingBraceOutdent();
this.foldingRules = new FoldMode();
}; };
oop.inherits(Mode, TextMode); oop.inherits(Mode, TextMode);