Merge pull request #1272 from ajaxorg/virtual_renderer
fix #1266: Scroller is collapsed when ace initialized with empty value
This commit is contained in:
commit
504faad85d
5 changed files with 102 additions and 113 deletions
|
|
@ -35,8 +35,6 @@
|
||||||
</li>
|
</li>
|
||||||
<li id="dropdown_EditSession.event.changeWrapMode" data-id="EditSession.event.changeWrapMode" class="memberLink"><a href="#EditSession.event.changeWrapMode" class="" title="EditSession.event.changeWrapMode (event)" data-id="EditSession.event.changeWrapMode">changeWrapMode</a>
|
<li id="dropdown_EditSession.event.changeWrapMode" data-id="EditSession.event.changeWrapMode" class="memberLink"><a href="#EditSession.event.changeWrapMode" class="" title="EditSession.event.changeWrapMode (event)" data-id="EditSession.event.changeWrapMode">changeWrapMode</a>
|
||||||
</li>
|
</li>
|
||||||
<li id="dropdown_EditSession.event.loadMode" data-id="EditSession.event.loadMode" class="memberLink"><a href="#EditSession.event.loadMode" class="" title="EditSession.event.loadMode (event)" data-id="EditSession.event.loadMode">loadMode</a>
|
|
||||||
</li>
|
|
||||||
<li id="dropdown_EditSession.event.tokenizerUpdate" data-id="EditSession.event.tokenizerUpdate" class="memberLink"><a href="#EditSession.event.tokenizerUpdate" class="" title="EditSession.event.tokenizerUpdate (event)" data-id="EditSession.event.tokenizerUpdate">tokenizerUpdate</a>
|
<li id="dropdown_EditSession.event.tokenizerUpdate" data-id="EditSession.event.tokenizerUpdate" class="memberLink"><a href="#EditSession.event.tokenizerUpdate" class="" title="EditSession.event.tokenizerUpdate (event)" data-id="EditSession.event.tokenizerUpdate">tokenizerUpdate</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -619,31 +617,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
<article id="EditSession.event.loadMode" data-title="EditSession.event.loadMode (event)" class="article">
|
|
||||||
<div class="section method">
|
|
||||||
<div class="memberContent">
|
|
||||||
<div class="title"><i id="EditSession.event.loadMode" class="methodToggle methodClicker inactive icon-caret-right"></i>
|
|
||||||
<ul class="signatures">
|
|
||||||
<li class="signature">
|
|
||||||
<ul>
|
|
||||||
<li class="signature-call"><span class="eventObjName">EditSession</span><span class="eventListenerStart">.on("</span><span id="EditSession.event.loadMode" class="member-name eventMember methodClicker">loadMode</span><span class="eventListenerClose">", </span><span class="eventFunctionOpen">function(</span><span class="eventFunctionClose">))</span></li>
|
|
||||||
</ul>
|
|
||||||
<ul class="metaInfo">
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="sideToggler">
|
|
||||||
<div id="ellipsis_EditSession.event.loadMode" class="ellipsis_description"><p>Emitted when the mode is loaded.</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="description"><p>Emitted when the mode is loaded.</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
<article id="EditSession.event.tokenizerUpdate" data-title="EditSession.event.tokenizerUpdate (event)" class="article">
|
<article id="EditSession.event.tokenizerUpdate" data-title="EditSession.event.tokenizerUpdate (event)" class="article">
|
||||||
<div class="section method">
|
<div class="section method">
|
||||||
<div class="memberContent">
|
<div class="memberContent">
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ exports.edit = function(el) {
|
||||||
var env = {
|
var env = {
|
||||||
document: doc,
|
document: doc,
|
||||||
editor: editor,
|
editor: editor,
|
||||||
onResize: editor.resize.bind(editor)
|
onResize: editor.resize.bind(editor, null)
|
||||||
};
|
};
|
||||||
event.addListener(window, "resize", env.onResize);
|
event.addListener(window, "resize", env.onResize);
|
||||||
editor.on("destroy", function() {
|
editor.on("destroy", function() {
|
||||||
|
|
|
||||||
|
|
@ -96,12 +96,6 @@ var config = require("./config");
|
||||||
* @param {Object} e An object containing one property, `"data"`, that contains information about the changing rows
|
* @param {Object} e An object containing one property, `"data"`, that contains information about the changing rows
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
/**
|
|
||||||
* Emitted when the mode is loaded.
|
|
||||||
*
|
|
||||||
* @event loadMode
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
/**
|
/**
|
||||||
* Emitted when the current mode changes.
|
* Emitted when the current mode changes.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -144,9 +144,34 @@ exports.getMatchOffsets = function(string, regExp) {
|
||||||
|
|
||||||
/* deprecated */
|
/* deprecated */
|
||||||
exports.deferredCall = function(fcn) {
|
exports.deferredCall = function(fcn) {
|
||||||
if (typeof console != "undefined" && console.error)
|
|
||||||
console.error("Deprecated: use lang.delayedCall")
|
var timer = null;
|
||||||
return exports.delayedCall(fcn);
|
var callback = function() {
|
||||||
|
timer = null;
|
||||||
|
fcn();
|
||||||
|
};
|
||||||
|
|
||||||
|
var deferred = function(timeout) {
|
||||||
|
deferred.cancel();
|
||||||
|
timer = setTimeout(callback, timeout || 0);
|
||||||
|
return deferred;
|
||||||
|
};
|
||||||
|
|
||||||
|
deferred.schedule = deferred;
|
||||||
|
|
||||||
|
deferred.call = function() {
|
||||||
|
this.cancel();
|
||||||
|
fcn();
|
||||||
|
return deferred;
|
||||||
|
};
|
||||||
|
|
||||||
|
deferred.cancel = function() {
|
||||||
|
clearTimeout(timer);
|
||||||
|
timer = null;
|
||||||
|
return deferred;
|
||||||
|
};
|
||||||
|
|
||||||
|
return deferred;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010, Ajax.org B.V.
|
* Copyright (c) 2010, Ajax.org B.V.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* * Neither the name of Ajax.org B.V. nor the
|
* * Neither the name of Ajax.org B.V. nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
|
@ -48,8 +48,6 @@ var editorCss = require("./requirejs/text!./css/editor.css");
|
||||||
dom.importCssString(editorCss, "ace_editor");
|
dom.importCssString(editorCss, "ace_editor");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* The class that is responsible for drawing everything you see on the screen!
|
* The class that is responsible for drawing everything you see on the screen!
|
||||||
* @class VirtualRenderer
|
* @class VirtualRenderer
|
||||||
**/
|
**/
|
||||||
|
|
@ -59,9 +57,6 @@ dom.importCssString(editorCss, "ace_editor");
|
||||||
* @param {DOMElement} container The root element of the editor
|
* @param {DOMElement} container The root element of the editor
|
||||||
* @param {String} theme The starting theme
|
* @param {String} theme The starting theme
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @constructor
|
* @constructor
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
@ -182,34 +177,34 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.CHANGE_H_SCROLL = 1024;
|
this.CHANGE_H_SCROLL = 1024;
|
||||||
|
|
||||||
oop.implement(this, EventEmitter);
|
oop.implement(this, EventEmitter);
|
||||||
|
|
||||||
this.updateCharacterSize = function() {
|
this.updateCharacterSize = function() {
|
||||||
if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
|
if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
|
||||||
this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
|
this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
|
||||||
this.setStyle("ace_nobold", !this.$allowBoldFonts);
|
this.setStyle("ace_nobold", !this.$allowBoldFonts);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.characterWidth = this.$textLayer.getCharacterWidth();
|
this.characterWidth = this.$textLayer.getCharacterWidth();
|
||||||
this.lineHeight = this.$textLayer.getLineHeight();
|
this.lineHeight = this.$textLayer.getLineHeight();
|
||||||
this.$updatePrintMargin();
|
this.$updatePrintMargin();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Associates the renderer with an [[EditSession `EditSession`]].
|
* Associates the renderer with an [[EditSession `EditSession`]].
|
||||||
**/
|
**/
|
||||||
this.setSession = function(session) {
|
this.setSession = function(session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
|
||||||
this.scroller.className = "ace_scroller";
|
this.scroller.className = "ace_scroller";
|
||||||
|
|
||||||
this.$cursorLayer.setSession(session);
|
this.$cursorLayer.setSession(session);
|
||||||
this.$markerBack.setSession(session);
|
this.$markerBack.setSession(session);
|
||||||
this.$markerFront.setSession(session);
|
this.$markerFront.setSession(session);
|
||||||
this.$gutterLayer.setSession(session);
|
this.$gutterLayer.setSession(session);
|
||||||
this.$textLayer.setSession(session);
|
this.$textLayer.setSession(session);
|
||||||
this.$loop.schedule(this.CHANGE_FULL);
|
this.$loop.schedule(this.CHANGE_FULL);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -217,7 +212,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* @param {Number} firstRow The first row to update
|
* @param {Number} firstRow The first row to update
|
||||||
* @param {Number} lastRow The last row to update
|
* @param {Number} lastRow The last row to update
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.updateLines = function(firstRow, lastRow) {
|
this.updateLines = function(firstRow, lastRow) {
|
||||||
if (lastRow === undefined)
|
if (lastRow === undefined)
|
||||||
|
|
@ -236,7 +231,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
if (this.$changedLines.lastRow < lastRow)
|
if (this.$changedLines.lastRow < lastRow)
|
||||||
this.$changedLines.lastRow = lastRow;
|
this.$changedLines.lastRow = lastRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.$changedLines.firstRow > this.layerConfig.lastRow ||
|
if (this.$changedLines.firstRow > this.layerConfig.lastRow ||
|
||||||
this.$changedLines.lastRow < this.layerConfig.firstRow)
|
this.$changedLines.lastRow < this.layerConfig.firstRow)
|
||||||
return;
|
return;
|
||||||
|
|
@ -259,19 +254,17 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* Triggers a full update of all the layers, for all the rows.
|
* Triggers a full update of all the layers, for all the rows.
|
||||||
* @param {Boolean} force If `true`, forces the changes through
|
* @param {Boolean} force If `true`, forces the changes through
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.updateFull = function(force) {
|
this.updateFull = function(force) {
|
||||||
if (force){
|
if (force)
|
||||||
this.$renderChanges(this.CHANGE_FULL, true);
|
this.$renderChanges(this.CHANGE_FULL, true);
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
this.$loop.schedule(this.CHANGE_FULL);
|
this.$loop.schedule(this.CHANGE_FULL);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Updates the font size.
|
* Updates the font size.
|
||||||
**/
|
**/
|
||||||
this.updateFontSize = function() {
|
this.updateFontSize = function() {
|
||||||
|
|
@ -285,10 +278,10 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* @param {Number} width The width of the editor in pixels
|
* @param {Number} width The width of the editor in pixels
|
||||||
* @param {Number} height The hiehgt of the editor, in pixels
|
* @param {Number} height The hiehgt of the editor, in pixels
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.onResize = function(force, gutterWidth, width, height) {
|
this.onResize = function(force, gutterWidth, width, height) {
|
||||||
var changes = this.CHANGE_SIZE;
|
var changes = 0;
|
||||||
var size = this.$size;
|
var size = this.$size;
|
||||||
|
|
||||||
if (this.resizing > 2)
|
if (this.resizing > 2)
|
||||||
|
|
@ -302,6 +295,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
|
|
||||||
if (height && (force || size.height != height)) {
|
if (height && (force || size.height != height)) {
|
||||||
size.height = height;
|
size.height = height;
|
||||||
|
changes = this.CHANGE_SIZE;
|
||||||
|
|
||||||
size.scrollerHeight = this.scroller.clientHeight;
|
size.scrollerHeight = this.scroller.clientHeight;
|
||||||
if (!size.scrollerHeight) {
|
if (!size.scrollerHeight) {
|
||||||
|
|
@ -321,6 +315,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
width = dom.getInnerWidth(this.container);
|
width = dom.getInnerWidth(this.container);
|
||||||
|
|
||||||
if (width && (force || this.resizing > 1 || size.width != width)) {
|
if (width && (force || this.resizing > 1 || size.width != width)) {
|
||||||
|
changes = this.CHANGE_SIZE;
|
||||||
size.width = width;
|
size.width = width;
|
||||||
|
|
||||||
var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
|
var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
|
||||||
|
|
@ -336,10 +331,10 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.$renderChanges(changes, true);
|
this.$renderChanges(changes, true);
|
||||||
else
|
else
|
||||||
this.$loop.schedule(changes);
|
this.$loop.schedule(changes);
|
||||||
|
|
||||||
if (force)
|
if (force)
|
||||||
this.$gutterLayer.$padding = null;
|
this.$gutterLayer.$padding = null;
|
||||||
|
|
||||||
if (force)
|
if (force)
|
||||||
delete this.resizing;
|
delete this.resizing;
|
||||||
};
|
};
|
||||||
|
|
@ -355,7 +350,6 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Adjusts the wrap limit, which is the number of characters that can fit within the width of the edit area on screen.
|
* Adjusts the wrap limit, which is the number of characters that can fit within the width of the edit area on screen.
|
||||||
**/
|
**/
|
||||||
this.adjustWrapLimit = function() {
|
this.adjustWrapLimit = function() {
|
||||||
|
|
@ -400,7 +394,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.getDisplayIndentGuides = function() {
|
this.getDisplayIndentGuides = function() {
|
||||||
return this.getOption("displayIndentGuides");
|
return this.getOption("displayIndentGuides");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setDisplayIndentGuides = function(display) {
|
this.setDisplayIndentGuides = function(display) {
|
||||||
this.setOption("displayIndentGuides", display);
|
this.setOption("displayIndentGuides", display);
|
||||||
};
|
};
|
||||||
|
|
@ -474,7 +468,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.$updateGutterLineHighlight = function() {
|
this.$updateGutterLineHighlight = function() {
|
||||||
var pos = this.$cursorLayer.$pixelPos;
|
var pos = this.$cursorLayer.$pixelPos;
|
||||||
var height = this.layerConfig.lineHeight;
|
var height = this.layerConfig.lineHeight;
|
||||||
if (this.session.getUseWrapMode()) {
|
if (this.session.getUseWrapMode()) {
|
||||||
var cursor = this.session.selection.getCursor();
|
var cursor = this.session.selection.getCursor();
|
||||||
cursor.column = 0;
|
cursor.column = 0;
|
||||||
pos = this.$cursorLayer.getPixelPosition(cursor, true);
|
pos = this.$cursorLayer.getPixelPosition(cursor, true);
|
||||||
|
|
@ -483,7 +477,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px";
|
this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px";
|
||||||
this.$gutterLineHighlight.style.height = height + "px";
|
this.$gutterLineHighlight.style.height = height + "px";
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$updatePrintMargin = function() {
|
this.$updatePrintMargin = function() {
|
||||||
if (!this.$showPrintMargin && !this.$printMarginEl)
|
if (!this.$showPrintMargin && !this.$printMarginEl)
|
||||||
return;
|
return;
|
||||||
|
|
@ -503,7 +497,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Returns the root element containing this renderer.
|
* Returns the root element containing this renderer.
|
||||||
* @returns {DOMElement}
|
* @returns {DOMElement}
|
||||||
**/
|
**/
|
||||||
|
|
@ -512,7 +506,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Returns the element that the mouse events are attached to
|
* Returns the element that the mouse events are attached to
|
||||||
* @returns {DOMElement}
|
* @returns {DOMElement}
|
||||||
**/
|
**/
|
||||||
|
|
@ -521,7 +515,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Returns the element to which the hidden text area is added.
|
* Returns the element to which the hidden text area is added.
|
||||||
* @returns {DOMElement}
|
* @returns {DOMElement}
|
||||||
**/
|
**/
|
||||||
|
|
@ -560,7 +554,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* [Returns the index of the first visible row.]{: #VirtualRenderer.getFirstVisibleRow}
|
* [Returns the index of the first visible row.]{: #VirtualRenderer.getFirstVisibleRow}
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
**/
|
**/
|
||||||
|
|
@ -569,7 +563,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Returns the index of the first fully visible row. "Fully" here means that the characters in the row are not truncated; that the top and the bottom of the row are on the screen.
|
* Returns the index of the first fully visible row. "Fully" here means that the characters in the row are not truncated; that the top and the bottom of the row are on the screen.
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
**/
|
**/
|
||||||
|
|
@ -578,7 +572,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Returns the index of the last fully visible row. "Fully" here means that the characters in the row are not truncated; that the top and the bottom of the row are on the screen.
|
* Returns the index of the last fully visible row. "Fully" here means that the characters in the row are not truncated; that the top and the bottom of the row are on the screen.
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
**/
|
**/
|
||||||
|
|
@ -588,7 +582,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* [Returns the index of the last visible row.]{: #VirtualRenderer.getLastVisibleRow}
|
* [Returns the index of the last visible row.]{: #VirtualRenderer.getLastVisibleRow}
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
**/
|
**/
|
||||||
|
|
@ -601,8 +595,8 @@ var VirtualRenderer = function(container, theme) {
|
||||||
/**
|
/**
|
||||||
* Sets the padding for all the layers.
|
* Sets the padding for all the layers.
|
||||||
* @param {Number} padding A new padding value (in pixels)
|
* @param {Number} padding A new padding value (in pixels)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.setPadding = function(padding) {
|
this.setPadding = function(padding) {
|
||||||
|
|
@ -616,7 +610,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Returns whether the horizontal scrollbar is set to be always visible.
|
* Returns whether the horizontal scrollbar is set to be always visible.
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
**/
|
**/
|
||||||
|
|
@ -625,10 +619,10 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifies whether you want to show the horizontal scrollbar or not.
|
* Identifies whether you want to show the horizontal scrollbar or not.
|
||||||
* @param {Boolean} alwaysVisible Set to `true` to make the horizontal scroll bar visible
|
* @param {Boolean} alwaysVisible Set to `true` to make the horizontal scroll bar visible
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
|
this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
|
||||||
if (this.$horizScrollAlwaysVisible != alwaysVisible) {
|
if (this.$horizScrollAlwaysVisible != alwaysVisible) {
|
||||||
|
|
@ -735,11 +729,14 @@ var VirtualRenderer = function(container, theme) {
|
||||||
|
|
||||||
if (changes & this.CHANGE_SIZE)
|
if (changes & this.CHANGE_SIZE)
|
||||||
this.$updateScrollBar();
|
this.$updateScrollBar();
|
||||||
|
|
||||||
this._signal("afterRender");
|
this._signal("afterRender");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$computeLayerConfig = function() {
|
this.$computeLayerConfig = function() {
|
||||||
|
if (!this.$size.scrollerHeight)
|
||||||
|
return this.onResize(true);
|
||||||
|
|
||||||
var session = this.session;
|
var session = this.session;
|
||||||
|
|
||||||
var offset = this.scrollTop % this.lineHeight;
|
var offset = this.scrollTop % this.lineHeight;
|
||||||
|
|
@ -845,7 +842,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Schedules an update to all the front markers in the document.
|
* Schedules an update to all the front markers in the document.
|
||||||
**/
|
**/
|
||||||
this.updateFrontMarkers = function() {
|
this.updateFrontMarkers = function() {
|
||||||
|
|
@ -854,7 +851,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Schedules an update to all the back markers in the document.
|
* Schedules an update to all the back markers in the document.
|
||||||
**/
|
**/
|
||||||
this.updateBackMarkers = function() {
|
this.updateBackMarkers = function() {
|
||||||
|
|
@ -862,8 +859,8 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.$loop.schedule(this.CHANGE_MARKER_BACK);
|
this.$loop.schedule(this.CHANGE_MARKER_BACK);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Deprecated; (moved to [[EditSession]])
|
* Deprecated; (moved to [[EditSession]])
|
||||||
* @deprecated
|
* @deprecated
|
||||||
**/
|
**/
|
||||||
|
|
@ -871,7 +868,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.$gutterLayer.addGutterDecoration(row, className);
|
this.$gutterLayer.addGutterDecoration(row, className);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deprecated; (moved to [[EditSession]])
|
* Deprecated; (moved to [[EditSession]])
|
||||||
* @deprecated
|
* @deprecated
|
||||||
**/
|
**/
|
||||||
|
|
@ -880,7 +877,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Redraw breakpoints.
|
* Redraw breakpoints.
|
||||||
**/
|
**/
|
||||||
this.updateBreakpoints = function(rows) {
|
this.updateBreakpoints = function(rows) {
|
||||||
|
|
@ -888,11 +885,11 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Sets annotations for the gutter.
|
* Sets annotations for the gutter.
|
||||||
* @param {Array} annotations An array containing annotations
|
* @param {Array} annotations An array containing annotations
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.setAnnotations = function(annotations) {
|
this.setAnnotations = function(annotations) {
|
||||||
this.$gutterLayer.setAnnotations(annotations);
|
this.$gutterLayer.setAnnotations(annotations);
|
||||||
|
|
@ -900,7 +897,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Updates the cursor icon.
|
* Updates the cursor icon.
|
||||||
**/
|
**/
|
||||||
this.updateCursor = function() {
|
this.updateCursor = function() {
|
||||||
|
|
@ -908,7 +905,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Hides the cursor icon.
|
* Hides the cursor icon.
|
||||||
**/
|
**/
|
||||||
this.hideCursor = function() {
|
this.hideCursor = function() {
|
||||||
|
|
@ -916,7 +913,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Shows the cursor icon.
|
* Shows the cursor icon.
|
||||||
**/
|
**/
|
||||||
this.showCursor = function() {
|
this.showCursor = function() {
|
||||||
|
|
@ -930,7 +927,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Scrolls the cursor into the first visibile area of the editor
|
* Scrolls the cursor into the first visibile area of the editor
|
||||||
**/
|
**/
|
||||||
this.scrollCursorIntoView = function(cursor, offset) {
|
this.scrollCursorIntoView = function(cursor, offset) {
|
||||||
|
|
@ -964,7 +961,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {:EditSession.getScrollTop}
|
* {:EditSession.getScrollTop}
|
||||||
* @related EditSession.getScrollTop
|
* @related EditSession.getScrollTop
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
|
|
@ -973,7 +970,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
return this.session.getScrollTop();
|
return this.session.getScrollTop();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {:EditSession.getScrollLeft}
|
* {:EditSession.getScrollLeft}
|
||||||
* @related EditSession.getScrollLeft
|
* @related EditSession.getScrollLeft
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
|
|
@ -983,7 +980,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Returns the first visible row, regardless of whether it's fully visible or not.
|
* Returns the first visible row, regardless of whether it's fully visible or not.
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
**/
|
**/
|
||||||
|
|
@ -992,7 +989,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Returns the last visible row, regardless of whether it's fully visible or not.
|
* Returns the last visible row, regardless of whether it's fully visible or not.
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
**/
|
**/
|
||||||
|
|
@ -1000,11 +997,11 @@ var VirtualRenderer = function(container, theme) {
|
||||||
return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
|
return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gracefully scrolls from the top of the editor to the row indicated.
|
* Gracefully scrolls from the top of the editor to the row indicated.
|
||||||
* @param {Number} row A row id
|
* @param {Number} row A row id
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @related EditSession.setScrollTop
|
* @related EditSession.setScrollTop
|
||||||
**/
|
**/
|
||||||
this.scrollToRow = function(row) {
|
this.scrollToRow = function(row) {
|
||||||
|
|
@ -1046,7 +1043,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* @param {Boolean} animate If `true` animates scrolling
|
* @param {Boolean} animate If `true` animates scrolling
|
||||||
* @param {Function} callback Function to be called after the animation has finished
|
* @param {Function} callback Function to be called after the animation has finished
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.scrollToLine = function(line, center, animate, callback) {
|
this.scrollToLine = function(line, center, animate, callback) {
|
||||||
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
|
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
|
||||||
|
|
@ -1093,7 +1090,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* Scrolls the editor to the y pixel indicated.
|
* Scrolls the editor to the y pixel indicated.
|
||||||
* @param {Number} scrollTop The position to scroll to
|
* @param {Number} scrollTop The position to scroll to
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
**/
|
**/
|
||||||
this.scrollToY = function(scrollTop) {
|
this.scrollToY = function(scrollTop) {
|
||||||
|
|
@ -1109,7 +1106,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* Scrolls the editor across the x-axis to the pixel indicated.
|
* Scrolls the editor across the x-axis to the pixel indicated.
|
||||||
* @param {Number} scrollLeft The position to scroll to
|
* @param {Number} scrollLeft The position to scroll to
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
**/
|
**/
|
||||||
this.scrollToX = function(scrollLeft) {
|
this.scrollToX = function(scrollLeft) {
|
||||||
|
|
@ -1126,7 +1123,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* @param {Number} deltaX The x value to scroll by
|
* @param {Number} deltaX The x value to scroll by
|
||||||
* @param {Number} deltaY The y value to scroll by
|
* @param {Number} deltaY The y value to scroll by
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.scrollBy = function(deltaX, deltaY) {
|
this.scrollBy = function(deltaX, deltaY) {
|
||||||
deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
|
deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
|
||||||
|
|
@ -1138,7 +1135,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* @param {Number} deltaX The x value to scroll by
|
* @param {Number} deltaX The x value to scroll by
|
||||||
* @param {Number} deltaY The y value to scroll by
|
* @param {Number} deltaY The y value to scroll by
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
**/
|
**/
|
||||||
this.isScrollableBy = function(deltaX, deltaY) {
|
this.isScrollableBy = function(deltaX, deltaY) {
|
||||||
|
|
@ -1177,7 +1174,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* @param {Number} row The document row position
|
* @param {Number} row The document row position
|
||||||
* @param {Number} column The document column position
|
* @param {Number} column The document column position
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
**/
|
**/
|
||||||
|
|
@ -1195,7 +1192,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Focuses the current container.
|
* Focuses the current container.
|
||||||
**/
|
**/
|
||||||
this.visualizeFocus = function() {
|
this.visualizeFocus = function() {
|
||||||
|
|
@ -1203,14 +1200,14 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Blurs the current container.
|
* Blurs the current container.
|
||||||
**/
|
**/
|
||||||
this.visualizeBlur = function() {
|
this.visualizeBlur = function() {
|
||||||
dom.removeCssClass(this.container, "ace_focus");
|
dom.removeCssClass(this.container, "ace_focus");
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Number} position
|
* @param {Number} position
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
|
@ -1238,7 +1235,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Hides the current composition.
|
* Hides the current composition.
|
||||||
**/
|
**/
|
||||||
this.hideComposition = function() {
|
this.hideComposition = function() {
|
||||||
|
|
@ -1255,13 +1252,13 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* [Sets a new theme for the editor. `theme` should exist, and be a directory path, like `ace/theme/textmate`.]{: #VirtualRenderer.setTheme}
|
* [Sets a new theme for the editor. `theme` should exist, and be a directory path, like `ace/theme/textmate`.]{: #VirtualRenderer.setTheme}
|
||||||
* @param {String} theme The path to a theme
|
* @param {String} theme The path to a theme
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.setTheme = function(theme) {
|
this.setTheme = function(theme) {
|
||||||
var _self = this;
|
var _self = this;
|
||||||
this.$themeValue = theme;
|
this.$themeValue = theme;
|
||||||
_self._dispatchEvent('themeChange',{theme:theme});
|
_self._dispatchEvent('themeChange',{theme:theme});
|
||||||
|
|
||||||
if (!theme || typeof theme == "string") {
|
if (!theme || typeof theme == "string") {
|
||||||
var moduleName = theme || "ace/theme/textmate";
|
var moduleName = theme || "ace/theme/textmate";
|
||||||
config.loadModule(["theme", moduleName], afterLoad);
|
config.loadModule(["theme", moduleName], afterLoad);
|
||||||
|
|
@ -1295,7 +1292,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
_self.$size.width = 0;
|
_self.$size.width = 0;
|
||||||
_self.onResize();
|
_self.onResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
_self._dispatchEvent('themeLoaded',{theme:theme});
|
_self._dispatchEvent('themeLoaded',{theme:theme});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1316,7 +1313,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* [Adds a new class, `style`, to the editor.]{: #VirtualRenderer.setStyle}
|
* [Adds a new class, `style`, to the editor.]{: #VirtualRenderer.setStyle}
|
||||||
* @param {String} style A class name
|
* @param {String} style A class name
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.setStyle = function setStyle(style, include) {
|
this.setStyle = function setStyle(style, include) {
|
||||||
dom.setCssClass(this.container, style, include != false);
|
dom.setCssClass(this.container, style, include != false);
|
||||||
|
|
@ -1326,14 +1323,14 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* [Removes the class `style` from the editor.]{: #VirtualRenderer.unsetStyle}
|
* [Removes the class `style` from the editor.]{: #VirtualRenderer.unsetStyle}
|
||||||
* @param {String} style A class name
|
* @param {String} style A class name
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
this.unsetStyle = function unsetStyle(style) {
|
this.unsetStyle = function unsetStyle(style) {
|
||||||
dom.removeCssClass(this.container, style);
|
dom.removeCssClass(this.container, style);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Destroys the text and cursor layers for this renderer.
|
* Destroys the text and cursor layers for this renderer.
|
||||||
**/
|
**/
|
||||||
this.destroy = function() {
|
this.destroy = function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue