commit
9696c1f9b3
6 changed files with 73 additions and 28 deletions
|
|
@ -491,10 +491,7 @@ var EditSession = function(text, mode) {
|
|||
*
|
||||
**/
|
||||
this.setOverwrite = function(overwrite) {
|
||||
if (this.$overwrite == overwrite) return;
|
||||
|
||||
this.$overwrite = overwrite;
|
||||
this._emit("changeOverwrite");
|
||||
this.setOption("overwrite", overwrite)
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1573,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) {
|
||||
|
|
@ -1588,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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -2394,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 {
|
||||
|
|
@ -2437,6 +2438,15 @@ config.defineOptions(EditSession.prototype, "session", {
|
|||
},
|
||||
initialValue: 4,
|
||||
handlesSet: true
|
||||
},
|
||||
overwrite: {
|
||||
set: function(val) {this._emit("changeOverwrite");},
|
||||
initialValue: false
|
||||
},
|
||||
newLineMode: {
|
||||
set: function(val) {this.doc.setNewLineMode(val)},
|
||||
get: function() {return this.doc.getNewLineMode(newLineMode)},
|
||||
handlesSet: true
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
@ -2219,21 +2216,27 @@ config.defineOptions(Editor.prototype, "editor", {
|
|||
behavioursEnabled: {initialValue: true},
|
||||
wrapBehavioursEnabled: {initialValue: true},
|
||||
|
||||
hScrollBarAlwaysVisible: "renderer",
|
||||
highlightGutterLine: "renderer",
|
||||
animatedScroll: "renderer",
|
||||
showInvisibles: "renderer",
|
||||
showPrintMargin: "renderer",
|
||||
printMarginColumn: "renderer",
|
||||
printMargin: "renderer",
|
||||
fadeFoldWidgets: "renderer",
|
||||
showFoldWidgets: "renderer",
|
||||
showGutter: "renderer",
|
||||
displayIndentGuides: "renderer",
|
||||
fontSize: "renderer",
|
||||
fontFamily: "renderer",
|
||||
|
||||
scrollSpeed: "$mouseHandler",
|
||||
dragDelay: "$mouseHandler",
|
||||
focusTimout: "$mouseHandler",
|
||||
|
||||
firstLineNumber: "session",
|
||||
overwrite: "session",
|
||||
newLineMode: "session",
|
||||
useWorker: "session",
|
||||
useSoftTabs: "session",
|
||||
tabSize: "session",
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ oop.inherits(Mode, TextMode);
|
|||
if (tok.type == KW_START || tok.type == KW_END)
|
||||
break;
|
||||
}
|
||||
if (!tok)
|
||||
if (!tok || tok.type == startToken.type)
|
||||
return;
|
||||
|
||||
var col = it.getCurrentTokenColumn();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ function FoldHandler(editor) {
|
|||
}
|
||||
});
|
||||
|
||||
editor.on("guttermousedown", function(e) {
|
||||
editor.on("gutterclick", function(e) {
|
||||
var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
|
||||
|
||||
if (gutterRegion == "foldWidgets") {
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ var MouseHandler = function(editor) {
|
|||
}).call(MouseHandler.prototype);
|
||||
|
||||
config.defineOptions(MouseHandler.prototype, "mouseHandler", {
|
||||
scrollSpeed: {initialValue: 1},
|
||||
scrollSpeed: {initialValue: 2},
|
||||
dragDelay: {initialValue: 150},
|
||||
focusTimout: {initialValue: 0}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -102,7 +102,6 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
// Indicates whether the horizontal scrollbar is visible
|
||||
this.$horizScroll = false;
|
||||
this.$horizScrollAlwaysVisible = false;
|
||||
|
||||
this.scrollBar = new ScrollBar(this.container);
|
||||
this.scrollBar.addEventListener("scroll", function(e) {
|
||||
|
|
@ -355,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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -494,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();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -615,7 +617,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
* @returns {Boolean}
|
||||
**/
|
||||
this.getHScrollBarAlwaysVisible = function() {
|
||||
return this.$horizScrollAlwaysVisible;
|
||||
return this.$hScrollBarAlwaysVisible;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -625,11 +627,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
*
|
||||
**/
|
||||
this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
|
||||
if (this.$horizScrollAlwaysVisible != alwaysVisible) {
|
||||
this.$horizScrollAlwaysVisible = alwaysVisible;
|
||||
if (!this.$horizScrollAlwaysVisible || !this.$horizScroll)
|
||||
this.$loop.schedule(this.CHANGE_SCROLL);
|
||||
}
|
||||
this.setOption("hScrollBarAlwaysVisible", alwaysVisible);
|
||||
};
|
||||
|
||||
this.$updateScrollBar = function() {
|
||||
|
|
@ -744,7 +742,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
var longestLine = this.$getLongestLine();
|
||||
|
||||
var horizScroll = this.$horizScrollAlwaysVisible || this.$size.scrollerWidth - longestLine < 0;
|
||||
var horizScroll = this.$hScrollBarAlwaysVisible || this.$size.scrollerWidth - longestLine < 0;
|
||||
var horizScrollChanged = this.$horizScroll !== horizScroll;
|
||||
this.$horizScroll = horizScroll;
|
||||
if (horizScrollChanged) {
|
||||
|
|
@ -1358,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";
|
||||
|
|
@ -1398,6 +1407,29 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", {
|
|||
},
|
||||
initialValue: false,
|
||||
value: true
|
||||
},
|
||||
hScrollBarAlwaysVisible: {
|
||||
set: function(alwaysVisible) {
|
||||
this.$hScrollBarAlwaysVisible = alwaysVisible;
|
||||
if (!this.$hScrollBarAlwaysVisible || !this.$horizScroll)
|
||||
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