Skip to content

Commit

Permalink
Make padding text layer specific so that print margin and active line…
Browse files Browse the repository at this point in the history
… highlight are not affected. ajaxorg#342
  • Loading branch information
Gozala committed Jul 14, 2011
1 parent 8c45e96 commit f90084b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
10 changes: 8 additions & 2 deletions lib/ace/layer/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ var Cursor = function(parentEl) {

(function() {

this.$padding = 0;
this.setPadding = function(padding) {
this.$padding = padding;
};

this.setSession = function(session) {
this.session = session;
};
Expand All @@ -66,7 +71,7 @@ var Cursor = function(parentEl) {
};

this.showCursor = function() {
this.isVisible = true;
this.isVisible = true;
dom.removeCssClass(this.cursor, "ace_hidden");
this.cursor.style.visibility = "visible";
this.restartTimer();
Expand Down Expand Up @@ -97,7 +102,8 @@ var Cursor = function(parentEl) {

var position = this.session.selection.getCursor();
var pos = this.session.documentToScreenPosition(position);
var cursorLeft = Math.round(pos.column * this.config.characterWidth);
var cursorLeft = Math.round(this.$padding +
pos.column * this.config.characterWidth);
var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
this.config.lineHeight;

Expand Down
15 changes: 12 additions & 3 deletions lib/ace/layer/marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ var Marker = function(parentEl) {

(function() {

this.$padding = 0;

this.setPadding = function(padding) {
this.$padding = padding;
};

this.setSession = function(session) {
this.session = session;
};
Expand All @@ -65,7 +71,7 @@ var Marker = function(parentEl) {

this.config = config;

var html = [];
var html = [];
for ( var key in this.markers) {
var marker = this.markers[key];

Expand All @@ -76,7 +82,9 @@ var Marker = function(parentEl) {

if (marker.renderer) {
var top = this.$getTop(range.start.row, config);
var left = Math.round(range.start.column * config.characterWidth);
var left = Math.round(this.$padding +
range.start.column *
config.characterWidth);
marker.renderer(html, range, left, top, config);
}
else if (range.isMultiLine()) {
Expand Down Expand Up @@ -162,7 +170,8 @@ var Marker = function(parentEl) {
var height = layerConfig.lineHeight;
var width = Math.round((range.end.column + (extraLength || 0) - range.start.column) * layerConfig.characterWidth);
var top = this.$getTop(range.start.row, layerConfig);
var left = Math.round(range.start.column * layerConfig.characterWidth);
var left = Math.round(this.$padding +
range.start.column * layerConfig.characterWidth);

stringBuilder.push(
"<div class='", clazz, "' style='",
Expand Down
7 changes: 7 additions & 0 deletions lib/ace/layer/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var EventEmitter = require("pilot/event_emitter").EventEmitter;
var Text = function(parentEl) {
this.element = dom.createElement("div");
this.element.className = "ace_layer ace_text-layer";
this.element.style.width = "auto";
parentEl.appendChild(this.element);

this.$characterSize = this.$measureSizes() || {width: 0, height: 0};
Expand All @@ -63,6 +64,12 @@ var Text = function(parentEl) {
this.EOL_CHAR = "&not;";
this.TAB_CHAR = "&rarr;";
this.SPACE_CHAR = "&middot;";
this.$padding = 0;

this.setPadding = function(padding) {
this.$padding = padding;
this.element.style.padding = "0 " + padding + "px";
};

this.getLineHeight = function() {
return this.$characterSize.height || 1;
Expand Down
7 changes: 5 additions & 2 deletions lib/ace/virtual_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ var VirtualRenderer = function(container, theme) {
this.$padding = null;
this.setPadding = function(padding) {
this.$padding = padding;
this.content.style.padding = "0 " + padding + "px";
this.$textLayer.setPadding(padding);
this.$cursorLayer.setPadding(padding);
this.$markerFront.setPadding(padding);
this.$markerBack.setPadding(padding);
this.$loop.schedule(this.CHANGE_FULL);
this.$updatePrintMargin();
};
Expand Down Expand Up @@ -577,7 +580,7 @@ var VirtualRenderer = function(container, theme) {
if (this.$textLayer.showInvisibles)
charCount += 1;

return Math.max(this.$size.scrollerWidth - this.$padding * 2, Math.round(charCount * this.characterWidth));
return Math.max(this.$size.scrollerWidth, Math.round(charCount * this.characterWidth));
};

this.updateFrontMarkers = function() {
Expand Down

0 comments on commit f90084b

Please sign in to comment.