Skip to content

Commit

Permalink
Bug 363714 - Need to be able to traverse out of editor with keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Li committed Mar 5, 2012
1 parent 816feb0 commit 84b7f10
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ function(messages, mUndoStack, mKeyBinding, mRulers, mAnnotations, mTextDND, mRe

this.textView.setKeyBinding(new mKeyBinding.KeyBinding(9, false, true), messages.unindentLines);
this.textView.setAction(messages.unindentLines, function() {
if(this.textView.isConsumingTabs() === false) {
return false;
}
var editor = this.editor;
var model = editor.getModel();
var selection = editor.getSelection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,14 @@ define("orion/textview/textView", ['orion/textview/textModel', 'orion/textview/k
}
return false;
},
/**
* Returns whether the text view is consuming tab keypresses.
*
* @returns {Boolean} <code>true</code> if tabs are being consumed by the textview
*/
isConsumingTabs: function() {
return this._tabMode;
},
/**
* Returns if the view is loaded.
* <p>
Expand Down Expand Up @@ -2638,13 +2646,13 @@ define("orion/textview/textView", ['orion/textview/textModel', 'orion/textview/k
if (a.userHandler) {
if (!a.userHandler()) {
if (a.defaultHandler) {
a.defaultHandler();
return a.defaultHandler();
} else {
return false;
}
}
} else if (a.defaultHandler) {
a.defaultHandler();
return a.defaultHandler();
}
break;
}
Expand Down Expand Up @@ -2935,6 +2943,9 @@ define("orion/textview/textView", ['orion/textview/textModel', 'orion/textview/k
return true;
},
_doTab: function (args) {
if(this._tabMode === false) {
return false;
}
var text = "\t";
if (this._expandTab) {
var model = this._model;
Expand All @@ -2948,6 +2959,14 @@ define("orion/textview/textView", ['orion/textview/textModel', 'orion/textview/k
return true;
},

_doTabMode: function (args) {
if(this._tabMode === undefined) {
this._tabMode = true;
}
this._tabMode = !this._tabMode;
return true;
},

/************************************ Internals ******************************************/
_applyStyle: function(style, node, reset) {
if (reset) {
Expand Down Expand Up @@ -3279,6 +3298,7 @@ define("orion/textview/textView", ['orion/textview/textModel', 'orion/textview/k
bindings.push({name: "enter", keyBinding: new KeyBinding(13), predefined: true});
bindings.push({name: "enter", keyBinding: new KeyBinding(13, null, true), predefined: true});
bindings.push({name: "selectAll", keyBinding: new KeyBinding('a', true), predefined: true});
bindings.push({name: "tabMode", keyBinding: new KeyBinding('m', true), predefined: true});
if (isMac) {
bindings.push({name: "deleteNext", keyBinding: new KeyBinding(46, null, true), predefined: true});
bindings.push({name: "deleteWordPrevious", keyBinding: new KeyBinding(8, null, null, true), predefined: true});
Expand Down Expand Up @@ -3374,7 +3394,9 @@ define("orion/textview/textView", ['orion/textview/textModel', 'orion/textview/k
{name: "selectAll", defaultHandler: function() {return self._doSelectAll();}},
{name: "copy", defaultHandler: function() {return self._doCopy();}},
{name: "cut", defaultHandler: function() {return self._doCut();}},
{name: "paste", defaultHandler: function() {return self._doPaste();}}
{name: "paste", defaultHandler: function() {return self._doPaste();}},

{name: "tabMode", defaultHandler: function() {return self._doTabMode();}}
];
},
_createLine: function(parent, div, document, lineIndex, model) {
Expand Down

0 comments on commit 84b7f10

Please sign in to comment.