size multiline markers with "right" instead of "width"

This commit is contained in:
nightwing 2012-06-11 11:08:24 +04:00
commit dbe4d0531e

View file

@ -73,7 +73,7 @@ var Marker = function(parentEl) {
var html = []; var html = [];
for ( var key in this.markers) { for (var key in this.markers) {
var marker = this.markers[key]; var marker = this.markers[key];
if (!marker.range) { if (!marker.range) {
@ -140,29 +140,25 @@ var Marker = function(parentEl) {
} }
}; };
// Draws a multi line marker, where lines span the full width // Draws a multi line marker, where lines span the full width
this.drawMultiLineMarker = function(stringBuilder, range, clazz, layerConfig, type) { this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, type) {
var padding = type === "background" ? 0 : this.$padding; var padding = type === "background" ? 0 : this.$padding;
var layerWidth = layerConfig.width + 2 * this.$padding - padding;
// from selection start to the end of the line // from selection start to the end of the line
var height = layerConfig.lineHeight; var height = config.lineHeight;
var width = Math.round(layerWidth - (range.start.column * layerConfig.characterWidth)); var top = this.$getTop(range.start.row, config);
var top = this.$getTop(range.start.row, layerConfig); var left = Math.round(padding + range.start.column * config.characterWidth);
var left = Math.round(
padding + range.start.column * layerConfig.characterWidth
);
stringBuilder.push( stringBuilder.push(
"<div class='", clazz, " start' style='", "<div class='", clazz, " start' style='",
"height:", height, "px;", "height:", height, "px;",
"width:", width, "px;", "right:0;",
"top:", top, "px;", "top:", top, "px;",
"left:", left, "px;'></div>" "left:", left, "px;'></div>"
); );
// from start of the last line to the selection end // from start of the last line to the selection end
top = this.$getTop(range.end.row, layerConfig); top = this.$getTop(range.end.row, config);
width = Math.round(range.end.column * layerConfig.characterWidth); var width = Math.round(range.end.column * config.characterWidth);
stringBuilder.push( stringBuilder.push(
"<div class='", clazz, "' style='", "<div class='", clazz, "' style='",
@ -173,15 +169,15 @@ var Marker = function(parentEl) {
); );
// all the complete lines // all the complete lines
height = (range.end.row - range.start.row - 1) * layerConfig.lineHeight; height = (range.end.row - range.start.row - 1) * config.lineHeight;
if (height < 0) if (height < 0)
return; return;
top = this.$getTop(range.start.row + 1, layerConfig); top = this.$getTop(range.start.row + 1, config);
stringBuilder.push( stringBuilder.push(
"<div class='", clazz, "' style='", "<div class='", clazz, "' style='",
"height:", height, "px;", "height:", height, "px;",
"width:", layerWidth, "px;", "right:0;",
"top:", top, "px;", "top:", top, "px;",
"left:", padding, "px;'></div>" "left:", padding, "px;'></div>"
); );