break demo into smaller parts
This commit is contained in:
parent
49a120990f
commit
6bdacdf69e
6 changed files with 756 additions and 384 deletions
48
demo/kitchen-sink/statusbar.js
Normal file
48
demo/kitchen-sink/statusbar.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
/** simple statusbar **/
|
||||
var dom = require("ace/lib/dom");
|
||||
var lang = require("ace/lib/lang");
|
||||
|
||||
var StatusBar = function(editor, parentNode) {
|
||||
this.element = dom.createElement("div");
|
||||
this.element.style.cssText = "color: gray; position:absolute; right:0; border-left:1px solid";
|
||||
parentNode.appendChild(this.element);
|
||||
|
||||
var statusUpdate = lang.deferredCall(function(){
|
||||
this.updateStatus(editor)
|
||||
}.bind(this));
|
||||
editor.on("changeStatus", function() {
|
||||
statusUpdate.schedule(50);
|
||||
});
|
||||
editor.on("changeSelection", function() {
|
||||
statusUpdate.schedule(50);
|
||||
});
|
||||
};
|
||||
|
||||
(function(){
|
||||
this.updateStatus = function(editor) {
|
||||
var status = [];
|
||||
function add(str, separator) {
|
||||
str && status.push(str, separator || "|")
|
||||
}
|
||||
|
||||
if (editor.$vimModeHandler)
|
||||
add(editor.$vimModeHandler.getStatusText());
|
||||
else if (editor.commands.recording)
|
||||
add("REC");
|
||||
|
||||
var c = editor.selection.lead;
|
||||
add(c.row + ":" + c.column, " ");
|
||||
if (!editor.selection.isEmpty()) {
|
||||
var r = editor.getSelectionRange()
|
||||
add("(" + (r.end.row - r.start.row) + ":" +(r.end.column - r.start.column) + ")");
|
||||
}
|
||||
status.pop();
|
||||
this.element.textContent = status.join("");
|
||||
}
|
||||
}).call(StatusBar.prototype)
|
||||
|
||||
exports.StatusBar = StatusBar;
|
||||
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue