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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue