2013-12-04 17:24:04 +00:00
|
|
|
define([
|
2013-12-04 22:50:01 +00:00
|
|
|
"editor",
|
|
|
|
"command"
|
|
|
|
], function(editor, command) {
|
2014-02-27 06:34:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
A module for changing the status text at the bottom of the window.
|
|
|
|
*/
|
2013-09-20 15:57:43 +00:00
|
|
|
|
|
|
|
var external = "";
|
|
|
|
var element = document.find(".status-text");
|
|
|
|
var update = function() {
|
|
|
|
var selection = editor.getSelection();
|
|
|
|
var displayText = "";
|
2013-09-20 19:42:24 +00:00
|
|
|
var cursor = selection.getCursor();
|
|
|
|
displayText = (cursor.row + 1) + ":" + (cursor.column + 1);
|
2013-09-20 15:57:43 +00:00
|
|
|
if (external) {
|
|
|
|
displayText += " - " + external;
|
|
|
|
}
|
|
|
|
element.innerHTML = displayText;
|
|
|
|
};
|
|
|
|
editor.on("changeSelection", update);
|
|
|
|
|
|
|
|
var toastTimeout = null;
|
|
|
|
|
2013-12-04 22:50:01 +00:00
|
|
|
var interface = {
|
2013-09-20 15:57:43 +00:00
|
|
|
setMessage: function(msg) {
|
|
|
|
external = msg;
|
|
|
|
if (toastTimeout !== null) {
|
|
|
|
clearTimeout(toastTimeout);
|
|
|
|
toastTimeout = null;
|
|
|
|
}
|
|
|
|
update();
|
|
|
|
},
|
|
|
|
clearMessage: function() {
|
|
|
|
external = "";
|
|
|
|
update();
|
|
|
|
},
|
|
|
|
toast: function(msg, seconds) {
|
|
|
|
external = msg;
|
2013-11-06 15:48:18 +00:00
|
|
|
update();
|
2013-09-20 15:57:43 +00:00
|
|
|
if (toastTimeout !== null) {
|
|
|
|
clearTimeout(toastTimeout);
|
|
|
|
}
|
|
|
|
toastTimeout = setTimeout(function() {
|
|
|
|
external = "";
|
|
|
|
update();
|
|
|
|
toastTimeout = null;
|
2014-02-27 06:34:02 +00:00
|
|
|
}, seconds ? seconds * 1000 : 5000);
|
2013-09-20 15:57:43 +00:00
|
|
|
}
|
2014-02-27 06:34:02 +00:00
|
|
|
};
|
2013-12-04 22:50:01 +00:00
|
|
|
|
|
|
|
command.on("status:set", interface.setMessage);
|
|
|
|
command.on("status:clear", interface.clearMessage);
|
|
|
|
command.on("status:toast", interface.toast);
|
|
|
|
|
|
|
|
return interface;
|
2013-09-20 15:57:43 +00:00
|
|
|
|
|
|
|
});
|