feature(edit) add go to line

This commit is contained in:
coderaiser 2013-11-20 15:46:17 +00:00
parent 6d5ee1f1d5
commit a73bc6b16a
2 changed files with 22 additions and 2 deletions

View file

@ -97,6 +97,7 @@ Edit
###Hot keys
- **F4** - open
- **Ctrl + s** - save
- **Ctrl + g** - go to line
- **Esc** - close
For more details see [Ace keyboard shortcuts](https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts "Ace keyboard shortcuts").

View file

@ -15,9 +15,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch;
Ace,
Msg,
Key = CloudCmd.Key,
Dialog = DOM.Dialog,
Images = DOM.Images,
Element;
function init() {
@ -92,6 +90,19 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch;
CloudCmd.View.hide();
};
this.goToLine = function() {
var dialog = DOM.Dialog,
msg = 'Line number:',
cursor = Ace.selection.getCursor(),
number = cursor.row + 1,
line = dialog.prompt(msg, number);
number = line - 0;
if (number)
Ace.gotoLine(number);
};
function focus() {
Ace.focus();
Ace.clearSelection();
@ -120,6 +131,14 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch;
}
});
Ace.commands.addCommand({
name : 'goToLine',
bindKey : { win: 'Ctrl-G', mac: 'Command-G' },
exec : function () {
Edit.goToLine();
}
});
Ace.commands.addCommand({
name : 'save',
bindKey : { win: 'Ctrl-S', mac: 'Command-S' },