cleanup
This commit is contained in:
parent
d0d3ca2de8
commit
3c46895f8c
4 changed files with 64 additions and 62 deletions
3
demo/demo_helper.js
Normal file
3
demo/demo_helper.js
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ace.require("ace/lib/net").get(document.baseURI, function(t){
|
||||
editor.setValue(t, 1);
|
||||
})
|
||||
|
|
@ -42,7 +42,7 @@ body {
|
|||
#controls td + td {
|
||||
text-align: left;
|
||||
}
|
||||
#lineColIndicator {
|
||||
.ace_status-indicator {
|
||||
color: gray;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
|
|
|
|||
|
|
@ -28,31 +28,30 @@
|
|||
background-color: rgb(245, 245, 245);
|
||||
color: gray;
|
||||
}
|
||||
#statusbar#lineColIndicator {
|
||||
border-left:1px solid;
|
||||
.ace_status-indicator {
|
||||
color: gray;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
border-left: 1px solid;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="editor">
|
||||
var editor = ace.edit("editor");
|
||||
var StatusBar = ace.require('ace/ext/statusbar').StatusBar;
|
||||
var statusBar = new StatusBar(editor, document.getElementById('statusBar'));
|
||||
editor.setTheme("ace/theme/twilight");
|
||||
editor.getSession().setMode("ace/mode/javascript");
|
||||
</pre>
|
||||
<pre id="editor"></pre>
|
||||
<div id="statusBar">ace rocks!</div>
|
||||
|
||||
<script src="../build/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../build/src-noconflict/ext-statusbar.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../build/src-noconflict/ace.js"></script>
|
||||
<script src="../build/src-noconflict/ext-statusbar.js"></script>
|
||||
<script>
|
||||
var editor = ace.edit("editor");
|
||||
var StatusBar = ace.require('ace/ext/statusbar').StatusBar;
|
||||
// create a simple selection status indicator
|
||||
var statusBar = new StatusBar(editor, document.getElementById('statusBar'));
|
||||
editor.setTheme("ace/theme/twilight");
|
||||
editor.getSession().setMode("ace/mode/javascript");
|
||||
editor.setTheme("ace/theme/dawn");
|
||||
editor.session.setMode("ace/mode/html");
|
||||
</script>
|
||||
|
||||
<script src="./demo_helper.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,49 +1,49 @@
|
|||
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.id = 'lineColIndicator';
|
||||
this.element.style.cssText = "display: inline-block;";
|
||||
parentNode.appendChild(this.element);
|
||||
|
||||
var statusUpdate = lang.delayedCall(function(){
|
||||
this.updateStatus(editor)
|
||||
}.bind(this));
|
||||
editor.on("changeStatus", function() {
|
||||
statusUpdate.schedule(100);
|
||||
});
|
||||
editor.on("changeSelection", function() {
|
||||
statusUpdate.schedule(100);
|
||||
});
|
||||
};
|
||||
|
||||
(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;
|
||||
|
||||
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.className = "ace_status-indicator";
|
||||
this.element.style.cssText = "display: inline-block;";
|
||||
parentNode.appendChild(this.element);
|
||||
|
||||
var statusUpdate = lang.delayedCall(function(){
|
||||
this.updateStatus(editor)
|
||||
}.bind(this));
|
||||
editor.on("changeStatus", function() {
|
||||
statusUpdate.schedule(100);
|
||||
});
|
||||
editor.on("changeSelection", function() {
|
||||
statusUpdate.schedule(100);
|
||||
});
|
||||
};
|
||||
|
||||
(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