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
|
||||
**/
|
||||
this.adjustWrapLimit = function(desiredLimit) {
|
||||
var wrapLimit = this.$constrainWrapLimit(desiredLimit);
|
||||
if (wrapLimit != this.$wrapLimit && wrapLimit > 0) {
|
||||
this.adjustWrapLimit = function(desiredLimit, $printMargin) {
|
||||
var limits = this.$wrapLimitRange
|
||||
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.$modified = true;
|
||||
if (this.$useWrapMode) {
|
||||
|
|
@ -1585,17 +1588,14 @@ var EditSession = function(text, mode) {
|
|||
return false;
|
||||
};
|
||||
|
||||
this.$constrainWrapLimit = function(wrapLimit) {
|
||||
var min = this.$wrapLimitRange.min;
|
||||
this.$constrainWrapLimit = function(wrapLimit, min, max) {
|
||||
if (min)
|
||||
wrapLimit = Math.max(min, wrapLimit);
|
||||
|
||||
var max = this.$wrapLimitRange.max;
|
||||
if (max)
|
||||
wrapLimit = Math.min(max, wrapLimit);
|
||||
|
||||
// What would a limit of 0 even mean?
|
||||
return Math.max(1, wrapLimit);
|
||||
return wrapLimit;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -2391,9 +2391,13 @@ config.defineOptions(EditSession.prototype, "session", {
|
|||
value = false;
|
||||
else if (value == "free")
|
||||
value = true;
|
||||
else if (value == "printMargin")
|
||||
value = -1;
|
||||
else if (typeof value == "string")
|
||||
value = parseInt(value, 10) || false;
|
||||
|
||||
if (this.$wrap == value)
|
||||
return;
|
||||
if (!value) {
|
||||
this.setUseWrapMode(false);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -344,10 +344,7 @@ var Editor = function(renderer, session) {
|
|||
*
|
||||
**/
|
||||
this.setFontSize = function(size) {
|
||||
if (typeof size == "number")
|
||||
size = size + "px";
|
||||
this.container.style.fontSize = size;
|
||||
this.renderer.updateFontSize();
|
||||
this.setOption("fontSize", size);
|
||||
};
|
||||
|
||||
this.$highlightBrackets = function() {
|
||||
|
|
@ -2225,10 +2222,13 @@ config.defineOptions(Editor.prototype, "editor", {
|
|||
showInvisibles: "renderer",
|
||||
showPrintMargin: "renderer",
|
||||
printMarginColumn: "renderer",
|
||||
printMargin: "renderer",
|
||||
fadeFoldWidgets: "renderer",
|
||||
showFoldWidgets: "renderer",
|
||||
showGutter: "renderer",
|
||||
displayIndentGuides: "renderer",
|
||||
fontSize: "renderer",
|
||||
fontFamily: "renderer",
|
||||
|
||||
scrollSpeed: "$mouseHandler",
|
||||
dragDelay: "$mouseHandler",
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.adjustWrapLimit = function() {
|
||||
var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
|
||||
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;
|
||||
style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
|
||||
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(); },
|
||||
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: {
|
||||
set: function(show){
|
||||
this.$gutter.style.display = show ? "block" : "none";
|
||||
|
|
@ -1401,6 +1415,21 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", {
|
|||
this.$loop.schedule(this.CHANGE_SCROLL);
|
||||
},
|
||||
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