Merge pull request #38 from b3log/gh-pages

提交错分支了,现合并到 master 上。
This commit is contained in:
Liang Ding 2014-09-11 19:24:47 +08:00
commit 1cff4fb4f0
2 changed files with 14 additions and 2 deletions

View File

@ -149,6 +149,7 @@ var editors = {
var editor = CodeMirror.fromTextArea(document.getElementById("editor" + id), {
lineNumbers: true,
autoCloseBrackets: true,
matchBrackets: true,
highlightSelectionMatches: {showToken: /\w/},
rulers: rulers,
styleActiveLine: true,
@ -171,6 +172,15 @@ var editors = {
"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.setValue(data.content);
editor.setOption("mode", data.mode);
@ -180,7 +190,7 @@ var editors = {
if ("text/x-go" === data.mode || "application/json" === data.mode) {
editor.setOption("lint", true);
}
if ("application/xml" === data.mode || "text/html" === data.mode) {
editor.setOption("autoCloseTags", true);
}

View File

@ -142,7 +142,8 @@
</div>
<div class="footer">
|
<span>|</span>
<span id="footer-cursor" style="float: right;"></span>
</div>
<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/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/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/search/searchcursor.js"></script>
<script type="text/javascript" src="{{.Wide.StaticServer}}/static/js/lib/codemirror-4.5/addon/search/match-highlighter.js"></script>