| 1 |
ace.define("ace/ext/statusbar",["require","exports","module","ace/lib/dom","ace/lib/lang"], function(require, exports, module){"use strict"; |
| 2 |
var dom = require("../lib/dom"); |
| 3 |
var lang = require("../lib/lang"); |
| 4 |
var StatusBar = (function () { |
| 5 |
function StatusBar(editor, parentNode) { |
| 6 |
this.element = dom.createElement("div"); |
| 7 |
this.element.className = "ace_status-indicator"; |
| 8 |
this.element.style.cssText = "display: inline-block;"; |
| 9 |
parentNode.appendChild(this.element); |
| 10 |
var statusUpdate = lang.delayedCall(function () { |
| 11 |
this.updateStatus(editor); |
| 12 |
}.bind(this)).schedule.bind(null, 100); |
| 13 |
editor.on("changeStatus", statusUpdate); |
| 14 |
editor.on("changeSelection", statusUpdate); |
| 15 |
editor.on("keyboardActivity", statusUpdate); |
| 16 |
} |
| 17 |
StatusBar.prototype.updateStatus = function (editor) { |
| 18 |
var status = []; |
| 19 |
function add(str, separator) { |
| 20 |
str && status.push(str, separator || "|"); |
| 21 |
} |
| 22 |
add(editor.keyBinding.getStatusText(editor)); |
| 23 |
if (editor.commands.recording) |
| 24 |
add("REC"); |
| 25 |
var sel = editor.selection; |
| 26 |
var c = sel.lead; |
| 27 |
if (!sel.isEmpty()) { |
| 28 |
var r = editor.getSelectionRange(); |
| 29 |
add("(" + (r.end.row - r.start.row) + ":" + (r.end.column - r.start.column) + ")", " "); |
| 30 |
} |
| 31 |
add(c.row + ":" + c.column, " "); |
| 32 |
if (sel.rangeCount) |
| 33 |
add("[" + sel.rangeCount + "]", " "); |
| 34 |
status.pop(); |
| 35 |
this.element.textContent = status.join(""); |
| 36 |
}; |
| 37 |
return StatusBar; |
| 38 |
}()); |
| 39 |
exports.StatusBar = StatusBar; |
| 40 |
|
| 41 |
}); (function() { |
| 42 |
ace.require(["ace/ext/statusbar"], function(m) { |
| 43 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 44 |
module.exports = m; |
| 45 |
} |
| 46 |
}); |
| 47 |
})(); |
| 48 |
|