add wrap: printMargin
This commit is contained in:
parent
b0338c15b4
commit
82f496a11f
3 changed files with 46 additions and 13 deletions
|
|
@ -1570,9 +1570,12 @@ var EditSession = function(text, mode) {
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
**/
|
**/
|
||||||
this.adjustWrapLimit = function(desiredLimit) {
|
this.adjustWrapLimit = function(desiredLimit, $printMargin) {
|
||||||
var wrapLimit = this.$constrainWrapLimit(desiredLimit);
|
var limits = this.$wrapLimitRange
|
||||||
if (wrapLimit != this.$wrapLimit && wrapLimit > 0) {
|
if (limits.max < 0)
|
||||||
|
limits = {min: $printMargin, max: $printMargin};
|
||||||
|
var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
|
||||||
|
if (wrapLimit != this.$wrapLimit && wrapLimit > 1) {
|
||||||
this.$wrapLimit = wrapLimit;
|
this.$wrapLimit = wrapLimit;
|
||||||
this.$modified = true;
|
this.$modified = true;
|
||||||
if (this.$useWrapMode) {
|
if (this.$useWrapMode) {
|
||||||
|
|
@ -1585,17 +1588,14 @@ var EditSession = function(text, mode) {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$constrainWrapLimit = function(wrapLimit) {
|
this.$constrainWrapLimit = function(wrapLimit, min, max) {
|
||||||
var min = this.$wrapLimitRange.min;
|
|
||||||
if (min)
|
if (min)
|
||||||
wrapLimit = Math.max(min, wrapLimit);
|
wrapLimit = Math.max(min, wrapLimit);
|
||||||
|
|
||||||
var max = this.$wrapLimitRange.max;
|
|
||||||
if (max)
|
if (max)
|
||||||
wrapLimit = Math.min(max, wrapLimit);
|
wrapLimit = Math.min(max, wrapLimit);
|
||||||
|
|
||||||
// What would a limit of 0 even mean?
|
return wrapLimit;
|
||||||
return Math.max(1, wrapLimit);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2391,9 +2391,13 @@ config.defineOptions(EditSession.prototype, "session", {
|
||||||
value = false;
|
value = false;
|
||||||
else if (value == "free")
|
else if (value == "free")
|
||||||
value = true;
|
value = true;
|
||||||
|
else if (value == "printMargin")
|
||||||
|
value = -1;
|
||||||
else if (typeof value == "string")
|
else if (typeof value == "string")
|
||||||
value = parseInt(value, 10) || false;
|
value = parseInt(value, 10) || false;
|
||||||
|
|
||||||
|
if (this.$wrap == value)
|
||||||
|
return;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
this.setUseWrapMode(false);
|
this.setUseWrapMode(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -344,10 +344,7 @@ var Editor = function(renderer, session) {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.setFontSize = function(size) {
|
this.setFontSize = function(size) {
|
||||||
if (typeof size == "number")
|
this.setOption("fontSize", size);
|
||||||
size = size + "px";
|
|
||||||
this.container.style.fontSize = size;
|
|
||||||
this.renderer.updateFontSize();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$highlightBrackets = function() {
|
this.$highlightBrackets = function() {
|
||||||
|
|
@ -2225,10 +2222,13 @@ config.defineOptions(Editor.prototype, "editor", {
|
||||||
showInvisibles: "renderer",
|
showInvisibles: "renderer",
|
||||||
showPrintMargin: "renderer",
|
showPrintMargin: "renderer",
|
||||||
printMarginColumn: "renderer",
|
printMarginColumn: "renderer",
|
||||||
|
printMargin: "renderer",
|
||||||
fadeFoldWidgets: "renderer",
|
fadeFoldWidgets: "renderer",
|
||||||
showFoldWidgets: "renderer",
|
showFoldWidgets: "renderer",
|
||||||
showGutter: "renderer",
|
showGutter: "renderer",
|
||||||
displayIndentGuides: "renderer",
|
displayIndentGuides: "renderer",
|
||||||
|
fontSize: "renderer",
|
||||||
|
fontFamily: "renderer",
|
||||||
|
|
||||||
scrollSpeed: "$mouseHandler",
|
scrollSpeed: "$mouseHandler",
|
||||||
dragDelay: "$mouseHandler",
|
dragDelay: "$mouseHandler",
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.adjustWrapLimit = function() {
|
this.adjustWrapLimit = function() {
|
||||||
var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
|
var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
|
||||||
var limit = Math.floor(availableWidth / this.characterWidth);
|
var limit = Math.floor(availableWidth / this.characterWidth);
|
||||||
return this.session.adjustWrapLimit(limit);
|
return this.session.adjustWrapLimit(limit, this.$showPrintMargin && this.$printMarginColumn);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -493,6 +493,9 @@ var VirtualRenderer = function(container, theme) {
|
||||||
var style = this.$printMarginEl.style;
|
var style = this.$printMarginEl.style;
|
||||||
style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
|
style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
|
||||||
style.visibility = this.$showPrintMargin ? "visible" : "hidden";
|
style.visibility = this.$showPrintMargin ? "visible" : "hidden";
|
||||||
|
|
||||||
|
if (this.session && this.session.$wrap == -1)
|
||||||
|
this.adjustWrapLimit();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1353,6 +1356,17 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", {
|
||||||
set: function() { this.$updatePrintMargin(); },
|
set: function() { this.$updatePrintMargin(); },
|
||||||
initialValue: 80
|
initialValue: 80
|
||||||
},
|
},
|
||||||
|
printMargin: {
|
||||||
|
set: function(val) {
|
||||||
|
if (typeof val == "number")
|
||||||
|
this.$printMarginColumn = val;
|
||||||
|
this.$showPrintMargin = !!val;
|
||||||
|
this.$updatePrintMargin();
|
||||||
|
},
|
||||||
|
get: function() {
|
||||||
|
return this.$showPrintMargin && this.$printMarginColumn;
|
||||||
|
}
|
||||||
|
},
|
||||||
showGutter: {
|
showGutter: {
|
||||||
set: function(show){
|
set: function(show){
|
||||||
this.$gutter.style.display = show ? "block" : "none";
|
this.$gutter.style.display = show ? "block" : "none";
|
||||||
|
|
@ -1401,6 +1415,21 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", {
|
||||||
this.$loop.schedule(this.CHANGE_SCROLL);
|
this.$loop.schedule(this.CHANGE_SCROLL);
|
||||||
},
|
},
|
||||||
initialValue: false
|
initialValue: false
|
||||||
|
},
|
||||||
|
fontSize: {
|
||||||
|
set: function(size) {
|
||||||
|
if (typeof size == "number")
|
||||||
|
size = size + "px";
|
||||||
|
this.container.style.fontSize = size;
|
||||||
|
this.updateFontSize();
|
||||||
|
},
|
||||||
|
initialValue: 12
|
||||||
|
},
|
||||||
|
fontFamily: {
|
||||||
|
set: function(name) {
|
||||||
|
this.container.style.fontFamily = name;
|
||||||
|
this.updateFontSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue