Skip to content

Instantly share code, notes, and snippets.

@pamelafox
Created May 15, 2012 22:11
Show Gist options
  • Save pamelafox/2705527 to your computer and use it in GitHub Desktop.
Save pamelafox/2705527 to your computer and use it in GitHub Desktop.
EditorManager + CommandManager
diff --git a/src/brackets.js b/src/brackets.js
index 39e30b2..cb20367 100644
--- a/src/brackets.js
+++ b/src/brackets.js
@@ -199,7 +199,8 @@ define(function (require, exports, module) {
//{"Ctrl-X": Commands.EDIT_CUT},
//{"Ctrl-C": Commands.EDIT_COPY},
//{"Ctrl-V": Commands.EDIT_PASTE},
-
+ {"Ctrl-I": Commands.SHOW_OTHER_STUFF},
+
{"Ctrl-A": Commands.EDIT_SELECT_ALL},
{"Ctrl-F": Commands.EDIT_FIND},
{"Ctrl-Shift-F": Commands.EDIT_FIND_IN_FILES},
diff --git a/src/command/Commands.js b/src/command/Commands.js
index a0aee81..fd36db3 100644
--- a/src/command/Commands.js
+++ b/src/command/Commands.js
@@ -82,5 +82,6 @@ define(function (require, exports, module) {
exports.DEBUG_USE_TAB_CHARS = "debug.useTabChars";
exports.HELP_ABOUT = "help.about";
+ exports.SHOW_OTHER_STUFF = "extensions.other";
});
diff --git a/src/editor/EditorManager.js b/src/editor/EditorManager.js
index 4dfc87e..0698048 100644
--- a/src/editor/EditorManager.js
+++ b/src/editor/EditorManager.js
@@ -133,18 +133,21 @@ define(function (require, exports, module) {
* @return {$.Promise} a promise that will be resolved when an InlineWidget
* is created or rejected when no inline editors are available.
*/
- function _openInlineWidget(editor) {
+ function _openInlineWidget(editor, provider) {
// Run through inline-editor providers until one responds
var pos = editor.getCursorPos(),
inlinePromise,
i,
result = new $.Deferred();
- for (i = 0; i < _inlineEditProviders.length && !inlinePromise; i++) {
- var provider = _inlineEditProviders[i];
- inlinePromise = provider(editor, pos);
+ if (!provider) {
+ for (i = 0; i < _inlineEditProviders.length && !inlinePromise; i++) {
+ provider = _inlineEditProviders[i];
+ }
}
-
+ console.log(provider);
+ inlinePromise = provider(editor, pos);
+
// If one of them will provide a widget, show it inline once ready
if (inlinePromise) {
inlinePromise.done(function (inlineWidget) {
@@ -496,7 +499,7 @@ define(function (require, exports, module) {
/**
* Show Inline Editor command handler
*/
- function _showInlineEditor() {
+ function _showInlineEditor(provider) {
if (_currentEditor) {
var inlineWidget = null,
result = getFocusedInlineWidget();
@@ -510,13 +513,13 @@ define(function (require, exports, module) {
inlineWidget.close();
} else {
// main editor has focus, so create an inline editor
- _openInlineWidget(_currentEditor);
+ _openInlineWidget(_currentEditor, provider);
}
}
}
-
+
CommandManager.register(Commands.SHOW_INLINE_EDITOR, _showInlineEditor);
-
+
// Initialize: register listeners
$(DocumentManager).on("currentDocumentChange", _onCurrentDocumentChange);
$(DocumentManager).on("workingSetRemove", _onWorkingSetRemove);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment