Merge branch 'master' of github.com:ajaxorg/ace

This commit is contained in:
Fabian Jakobs 2011-12-19 13:21:18 +01:00
commit b8f15cb81b
5 changed files with 16 additions and 11 deletions

View file

@ -140,10 +140,11 @@ var Marker = function(parentEl) {
* Draws a multi line marker, where lines span the full width
*/
this.drawMultiLineMarker = function(stringBuilder, range, clazz, layerConfig, type) {
// from selection start to the end of the line
var padding = type === "background" ? 0 : this.$padding;
var layerWidth = layerConfig.width + 2 * this.$padding - padding;
// from selection start to the end of the line
var height = layerConfig.lineHeight;
var width = Math.round(layerConfig.width - (range.start.column * layerConfig.characterWidth));
var width = Math.round(layerWidth - (range.start.column * layerConfig.characterWidth));
var top = this.$getTop(range.start.row, layerConfig);
var left = Math.round(
padding + range.start.column * layerConfig.characterWidth
@ -174,12 +175,11 @@ var Marker = function(parentEl) {
if (height < 0)
return;
top = this.$getTop(range.start.row + 1, layerConfig);
width = layerConfig.width;
stringBuilder.push(
"<div class='", clazz, "' style='",
"height:", height, "px;",
"width:", width, "px;",
"width:", layerWidth, "px;",
"top:", top, "px;",
"left:", padding, "px;'></div>"
);

View file

@ -49,7 +49,7 @@ var oop = require("../lib/oop");
function Mode() {
this.$tokenizer = new Tokenizer(new Rules().getRules());
this.$outdent = new Outdent();
this.foldingRules = new PythonFoldMode("\\[|=|(=>)|(->)");
this.foldingRules = new PythonFoldMode("=|=>|->|\\s*class [^#]*");
}
oop.inherits(Mode, TextMode);

View file

@ -41,7 +41,7 @@ var oop = require("../../lib/oop");
var BaseFoldMode = require("./fold_mode").FoldMode;
var FoldMode = exports.FoldMode = function(markers) {
this.foldingStartMarker = new RegExp("(?:(\\[)|" + markers + ")(?:\\s*)(?:#.*)?$");
this.foldingStartMarker = new RegExp("(?:([\\[{])|(" + markers + "))(?:\\s*)(?:#.*)?$");
};
oop.inherits(FoldMode, BaseFoldMode);
@ -53,8 +53,9 @@ oop.inherits(FoldMode, BaseFoldMode);
if (match) {
if (match[1])
return this.openingBracketBlock(session, match[1], row, match.index);
return this.indentationBlock(session, row, match.index + 1);
if (match[2])
return this.indentationBlock(session, row, match.index + match[2].length);
return this.indentationBlock(session, row);
}
}

View file

@ -52,6 +52,7 @@ module.exports = {
'stuff',
']',
'[ '
'{ '
]);
var mode = new PythonMode();
@ -62,6 +63,7 @@ module.exports = {
assert.equal(session.getFoldWidget(1), "");
assert.equal(session.getFoldWidget(2), "");
assert.equal(session.getFoldWidget(3), "start");
assert.equal(session.getFoldWidget(4), "start");
assert.range(session.getFoldWidgetRange(0), 0, 1, 2, 0);
assert.equal(session.getFoldWidgetRange(3), null);

View file

@ -646,12 +646,14 @@ var VirtualRenderer = function(container, theme) {
var scrollLeft = this.scroller.scrollLeft;
if (scrollLeft > left) {
if (left < this.$padding + 2 * this.layerConfig.characterWidth)
left = 0;
this.scrollToX(left);
}
if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
if (left > this.layerConfig.width)
this.$desiredScrollLeft = left + 2 * this.characterWidth;
if (left > this.layerConfig.width + 2 * this.$padding)
this.$desiredScrollLeft = left;
else
this.scrollToX(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
}
@ -702,7 +704,7 @@ var VirtualRenderer = function(container, theme) {
};
this.scrollToX = function(scrollLeft) {
if (scrollLeft <= this.$padding + 2 * this.layerConfig.characterWidth)
if (scrollLeft <= this.$padding)
scrollLeft = 0;
this.scroller.scrollLeft = scrollLeft;