Sin descripción
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.

ext-statusbar.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ace.define("ace/ext/statusbar",["require","exports","module","ace/lib/dom","ace/lib/lang"], 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));
  13. editor.on("changeStatus", function() {
  14. statusUpdate.schedule(100);
  15. });
  16. editor.on("changeSelection", function() {
  17. statusUpdate.schedule(100);
  18. });
  19. };
  20. (function(){
  21. this.updateStatus = function(editor) {
  22. var status = [];
  23. function add(str, separator) {
  24. str && status.push(str, separator || "|");
  25. }
  26. add(editor.keyBinding.getStatusText(editor));
  27. if (editor.commands.recording)
  28. add("REC");
  29. var c = editor.selection.lead;
  30. add(c.row + ":" + c.column, " ");
  31. if (!editor.selection.isEmpty()) {
  32. var r = editor.getSelectionRange();
  33. add("(" + (r.end.row - r.start.row) + ":" +(r.end.column - r.start.column) + ")");
  34. }
  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() {});
  43. })();