Select folds as the user clicks on it and expand them on double clicking

This commit is contained in:
Julian Viereck 2011-05-20 19:13:11 +02:00
commit fe4465fe23
2 changed files with 45 additions and 26 deletions

View file

@ -154,6 +154,10 @@
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
} }
.ace_line .ace_fold {
cursor: pointer;
}
.ace_dragging .ace_marker-layer, .ace_dragging .ace_text-layer { .ace_dragging .ace_marker-layer, .ace_dragging .ace_text-layer {
cursor: move; cursor: move;
} }

View file

@ -112,6 +112,13 @@ var MouseHandler = function(editor) {
} }
return; return;
} else { } else {
// Select the fold as the user clicks it.
var fold = editor.session.getFoldAt(pos.row, pos.column, 1);
if (fold) {
editor.selection.setSelectionRange(fold.range);
return;
}
inSelection = !editor.getReadOnly() inSelection = !editor.getReadOnly()
&& !selectionEmpty && !selectionEmpty
&& selectionRange.contains(pos.row, pos.column); && selectionRange.contains(pos.row, pos.column);
@ -255,10 +262,18 @@ var MouseHandler = function(editor) {
}; };
this.onMouseDoubleClick = function(e) { this.onMouseDoubleClick = function(e) {
var editor = this.editor;
var pos = this.$getEventPosition(e); var pos = this.$getEventPosition(e);
this.editor.moveCursorToPosition(pos);
this.editor.selection.selectWord(); // If the user dclicked on a fold, then expand it.
this.$clickSelection = this.editor.getSelectionRange(); var fold = editor.session.getFoldAt(pos.row, pos.column, 1);
if (fold) {
editor.session.expandFold(fold);
} else {
editor.moveCursorToPosition(pos);
editor.selection.selectWord();
this.$clickSelection = editor.getSelectionRange();
}
}; };
this.onMouseTripleClick = function(e) { this.onMouseTripleClick = function(e) {