mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
|
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.className = "ace_status-indicator";
|
||
|
this.element.style.cssText = "display: inline-block;";
|
||
|
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;
|
||
|
|
||
|
});
|