adds statusbar to extensions
the only thing changed is the statusbar's inline styling has been removed.
This commit is contained in:
parent
19dd921127
commit
640c72f44a
1 changed files with 48 additions and 0 deletions
48
lib/ace/ext/statusbar.js
Normal file
48
lib/ace/ext/statusbar.js
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
/** simple statusbar **/
|
||||||
|
var dom = require("ace/lib/dom");
|
||||||
|
var lang = require("ace/lib/lang");
|
||||||
|
|
||||||
|
var StatusBar = function(editor, parentNode) {
|
||||||
|
this.element = dom.createElement("div");
|
||||||
|
this.element.id = 'lineColIndicator';
|
||||||
|
parentNode.appendChild(this.element);
|
||||||
|
|
||||||
|
var statusUpdate = lang.delayedCall(function(){
|
||||||
|
this.updateStatus(editor)
|
||||||
|
}.bind(this));
|
||||||
|
editor.on("changeStatus", function() {
|
||||||
|
statusUpdate.schedule(100);
|
||||||
|
});
|
||||||
|
editor.on("changeSelection", function() {
|
||||||
|
statusUpdate.schedule(100);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
(function(){
|
||||||
|
this.updateStatus = function(editor) {
|
||||||
|
var status = [];
|
||||||
|
function add(str, separator) {
|
||||||
|
str && status.push(str, separator || "|");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (editor.$vimModeHandler)
|
||||||
|
add(editor.$vimModeHandler.getStatusText());
|
||||||
|
else if (editor.commands.recording)
|
||||||
|
add("REC");
|
||||||
|
|
||||||
|
var c = editor.selection.lead;
|
||||||
|
add(c.row + ":" + c.column, " ");
|
||||||
|
if (!editor.selection.isEmpty()) {
|
||||||
|
var r = editor.getSelectionRange();
|
||||||
|
add("(" + (r.end.row - r.start.row) + ":" +(r.end.column - r.start.column) + ")");
|
||||||
|
}
|
||||||
|
status.pop();
|
||||||
|
this.element.textContent = status.join("");
|
||||||
|
};
|
||||||
|
}).call(StatusBar.prototype);
|
||||||
|
|
||||||
|
exports.StatusBar = StatusBar;
|
||||||
|
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue