commit
1cff4fb4f0
|
@ -149,6 +149,7 @@ var editors = {
|
||||||
var editor = CodeMirror.fromTextArea(document.getElementById("editor" + id), {
|
var editor = CodeMirror.fromTextArea(document.getElementById("editor" + id), {
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
autoCloseBrackets: true,
|
autoCloseBrackets: true,
|
||||||
|
matchBrackets: true,
|
||||||
highlightSelectionMatches: {showToken: /\w/},
|
highlightSelectionMatches: {showToken: /\w/},
|
||||||
rulers: rulers,
|
rulers: rulers,
|
||||||
styleActiveLine: true,
|
styleActiveLine: true,
|
||||||
|
@ -171,6 +172,15 @@ var editors = {
|
||||||
"Ctrl-D": "doNothing" // 取消默认的 deleteLine
|
"Ctrl-D": "doNothing" // 取消默认的 deleteLine
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
editor.on('cursorActivity', function(cm) {
|
||||||
|
var cursor = cm.getCursor();
|
||||||
|
|
||||||
|
$("#footer-cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
|
||||||
|
// TODO: 关闭 tab 的时候要重置
|
||||||
|
// TODO: 保存当前编辑器光标位置,切换 tab 的时候要设置回来
|
||||||
|
});
|
||||||
|
|
||||||
editor.setSize('100%', $(".edit-panel").height() - $(".edit-header").height());
|
editor.setSize('100%', $(".edit-panel").height() - $(".edit-header").height());
|
||||||
editor.setValue(data.content);
|
editor.setValue(data.content);
|
||||||
editor.setOption("mode", data.mode);
|
editor.setOption("mode", data.mode);
|
||||||
|
@ -180,7 +190,7 @@ var editors = {
|
||||||
if ("text/x-go" === data.mode || "application/json" === data.mode) {
|
if ("text/x-go" === data.mode || "application/json" === data.mode) {
|
||||||
editor.setOption("lint", true);
|
editor.setOption("lint", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("application/xml" === data.mode || "text/html" === data.mode) {
|
if ("application/xml" === data.mode || "text/html" === data.mode) {
|
||||||
editor.setOption("autoCloseTags", true);
|
editor.setOption("autoCloseTags", true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
|
|
<span>|</span>
|
||||||
|
<span id="footer-cursor" style="float: right;"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -168,6 +169,7 @@
|
||||||
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/display/fullscreen.js"></script>
|
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/display/fullscreen.js"></script>
|
||||||
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/display/rulers.js"></script>
|
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/display/rulers.js"></script>
|
||||||
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/edit/closebrackets.js"></script>
|
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/edit/closebrackets.js"></script>
|
||||||
|
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/edit/matchbrackets.js"></script>
|
||||||
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/edit/closetag.js"></script>
|
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/edit/closetag.js"></script>
|
||||||
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/search/searchcursor.js"></script>
|
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/search/searchcursor.js"></script>
|
||||||
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/search/match-highlighter.js"></script>
|
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/search/match-highlighter.js"></script>
|
||||||
|
|
Loading…
Reference in New Issue