ext-statusbar.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ace.define("ace/ext/statusbar",[], function(require, exports, module) {
  2. "use strict";
  3. var dom = require("ace/lib/dom");
  4. var lang = require("ace/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. });
  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. })();