You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7 KiB

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