ext-statusbar.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. define("ace/ext/statusbar",["ace_require","exports","module","ace/lib/dom","ace/lib/lang"], function(ace_require, exports, module) {
  2. "use strict";
  3. var dom = ace_require("../lib/dom");
  4. var lang = ace_require("../lib/lang");
  5. var StatusBar = function(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. (function(){
  18. this.updateStatus = function(editor) {
  19. var status = [];
  20. function add(str, separator) {
  21. str && status.push(str, separator || "|");
  22. }
  23. add(editor.keyBinding.getStatusText(editor));
  24. if (editor.commands.recording)
  25. add("REC");
  26. var sel = editor.selection;
  27. var c = sel.lead;
  28. if (!sel.isEmpty()) {
  29. var r = editor.getSelectionRange();
  30. add("(" + (r.end.row - r.start.row) + ":" +(r.end.column - r.start.column) + ")", " ");
  31. }
  32. add(c.row + ":" + c.column, " ");
  33. if (sel.rangeCount)
  34. add("[" + sel.rangeCount + "]", " ");
  35. status.pop();
  36. this.element.textContent = status.join("");
  37. };
  38. }).call(StatusBar.prototype);
  39. exports.StatusBar = StatusBar;
  40. }); (function() {
  41. window.ace_require(["ace/ext/statusbar"], function(m) {
  42. if (typeof module == "object" && typeof exports == "object" && module) {
  43. module.exports = m;
  44. }
  45. });
  46. })();