move horizontal scrollbar always visible setting to window model
This commit is contained in:
parent
1657ffb93e
commit
069293b3ff
5 changed files with 31 additions and 22 deletions
|
|
@ -339,7 +339,7 @@ define(function(require, exports, module) {
|
||||||
showGutterEl.checked = editor.getShowGutter();
|
showGutterEl.checked = editor.getShowGutter();
|
||||||
showPrintMarginEl.checked = editor.getShowPrintMargin();
|
showPrintMarginEl.checked = editor.getShowPrintMargin();
|
||||||
highlightSelectedWordE.checked = editor.getHighlightSelectedWord();
|
highlightSelectedWordE.checked = editor.getHighlightSelectedWord();
|
||||||
showHScrollEl.checked = editor.renderer.getHScrollBarAlwaysVisible();
|
showHScrollEl.checked = editor.getHScrollBarAlwaysVisible();
|
||||||
softTabEl.checked = session.getUseSoftTabs();
|
softTabEl.checked = session.getUseSoftTabs();
|
||||||
behavioursEl.checked = editor.getBehavioursEnabled()
|
behavioursEl.checked = editor.getBehavioursEnabled()
|
||||||
}
|
}
|
||||||
|
|
@ -418,7 +418,7 @@ define(function(require, exports, module) {
|
||||||
});
|
});
|
||||||
|
|
||||||
bindCheckbox("show_hscroll", function(checked) {
|
bindCheckbox("show_hscroll", function(checked) {
|
||||||
env.editor.renderer.setHScrollBarAlwaysVisible(checked);
|
env.editor.setHScrollBarAlwaysVisible(checked);
|
||||||
});
|
});
|
||||||
|
|
||||||
bindCheckbox("soft_tab", function(checked) {
|
bindCheckbox("soft_tab", function(checked) {
|
||||||
|
|
|
||||||
|
|
@ -651,6 +651,14 @@ var Editor = function(windowView, buffer) {
|
||||||
return this.windowModel.getShowGutter();
|
return this.windowModel.getShowGutter();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
|
||||||
|
this.windowModel.setHScrollBarAlwaysVisible(alwaysVisible);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.getHScrollBarAlwaysVisible = function() {
|
||||||
|
return this.windowModel.getHScrollBarAlwaysVisible();
|
||||||
|
};
|
||||||
|
|
||||||
this.$readOnly = false;
|
this.$readOnly = false;
|
||||||
this.setReadOnly = function(readOnly) {
|
this.setReadOnly = function(readOnly) {
|
||||||
this.$readOnly = readOnly;
|
this.$readOnly = readOnly;
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ var Window = exports.Window = function() {
|
||||||
this.printMarginColumn = 80;
|
this.printMarginColumn = 80;
|
||||||
this.showGutter = true;
|
this.showGutter = true;
|
||||||
this.padding = 4;
|
this.padding = 4;
|
||||||
|
this.horizScrollAlwaysVisible = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
@ -150,7 +151,19 @@ var Window = exports.Window = function() {
|
||||||
|
|
||||||
this.getPadding = function() {
|
this.getPadding = function() {
|
||||||
return this.padding;
|
return this.padding;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
|
||||||
|
if (this.horizScrollAlwaysVisible == alwaysVisible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.horizScrollAlwaysVisible = alwaysVisible;
|
||||||
|
this._emit("changeHorizScroll");
|
||||||
|
};
|
||||||
|
|
||||||
|
this.getHScrollBarAlwaysVisible = function() {
|
||||||
|
return this.horizScrollAlwaysVisible;
|
||||||
|
};
|
||||||
|
|
||||||
}).call(Window.prototype);
|
}).call(Window.prototype);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,20 +89,13 @@ var WindowView = function(windowModel, container, theme) {
|
||||||
this.$cursorLayer = new CursorLayer(windowModel, this.content);
|
this.$cursorLayer = new CursorLayer(windowModel, this.content);
|
||||||
this.$cursorPadding = 8;
|
this.$cursorPadding = 8;
|
||||||
|
|
||||||
// Indicates whether the horizontal scrollbar is visible
|
|
||||||
this.$horizScroll = true;
|
this.$horizScroll = true;
|
||||||
this.$horizScrollAlwaysVisible = true;
|
|
||||||
|
|
||||||
this.scrollBar = new ScrollBar(container);
|
this.scrollBar = new ScrollBar(container);
|
||||||
this.scrollBar.addEventListener("scroll", this.onScroll.bind(this));
|
this.scrollBar.addEventListener("scroll", this.onScroll.bind(this));
|
||||||
|
|
||||||
this.scrollTop = 0;
|
this.scrollTop = 0;
|
||||||
|
|
||||||
this.cursorPos = {
|
|
||||||
row : 0,
|
|
||||||
column : 0
|
|
||||||
};
|
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
this.$textLayer.addEventListener("changeCharaterSize", function() {
|
this.$textLayer.addEventListener("changeCharaterSize", function() {
|
||||||
_self.characterWidth = textLayer.getCharacterWidth();
|
_self.characterWidth = textLayer.getCharacterWidth();
|
||||||
|
|
@ -120,6 +113,7 @@ var WindowView = function(windowModel, container, theme) {
|
||||||
|
|
||||||
this.updatePadding();
|
this.updatePadding();
|
||||||
this.updatePrintMargin();
|
this.updatePrintMargin();
|
||||||
|
this.updateHorizScroll();
|
||||||
};
|
};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
@ -324,16 +318,9 @@ var WindowView = function(windowModel, container, theme) {
|
||||||
this.updatePrintMargin();
|
this.updatePrintMargin();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getHScrollBarAlwaysVisible = function() {
|
this.updateHorizScroll = function() {
|
||||||
return this.$horizScrollAlwaysVisible;
|
if (!this.model.horizScrollAlwaysVisible || !this.$horizScroll)
|
||||||
};
|
this.$loop.schedule(this.CHANGE_SCROLL);
|
||||||
|
|
||||||
this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
|
|
||||||
if (this.$horizScrollAlwaysVisible != alwaysVisible) {
|
|
||||||
this.$horizScrollAlwaysVisible = alwaysVisible;
|
|
||||||
if (!this.$horizScrollAlwaysVisible || !this.$horizScroll)
|
|
||||||
this.$loop.schedule(this.CHANGE_SCROLL);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onScroll = function(e) {
|
this.onScroll = function(e) {
|
||||||
|
|
@ -425,7 +412,7 @@ var WindowView = function(windowModel, container, theme) {
|
||||||
var longestLine = this.$getLongestLine();
|
var longestLine = this.$getLongestLine();
|
||||||
var widthChanged = this.model.layerConfig.width != longestLine;
|
var widthChanged = this.model.layerConfig.width != longestLine;
|
||||||
|
|
||||||
var horizScroll = this.$horizScrollAlwaysVisible || this.model.size.scrollerWidth - longestLine < 0;
|
var horizScroll = this.model.horizScrollAlwaysVisible || this.model.size.scrollerWidth - longestLine < 0;
|
||||||
var horizScrollChanged = this.$horizScroll !== horizScroll;
|
var horizScrollChanged = this.$horizScroll !== horizScroll;
|
||||||
this.$horizScroll = horizScroll;
|
this.$horizScroll = horizScroll;
|
||||||
if (horizScrollChanged)
|
if (horizScrollChanged)
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ var WindowController = exports.WindowController = function(model, view) {
|
||||||
model.on("changePrintMargin", view.updatePrintMargin.bind(view));
|
model.on("changePrintMargin", view.updatePrintMargin.bind(view));
|
||||||
model.on("changeShowGutter", view.updateShowGutter.bind(view));
|
model.on("changeShowGutter", view.updateShowGutter.bind(view));
|
||||||
model.on("changePadding", view.updatePadding.bind(view));
|
model.on("changePadding", view.updatePadding.bind(view));
|
||||||
|
model.on("changeHorizScroll", view.updateHorizScroll.bind(view));
|
||||||
};
|
};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue