How to use the editor/EditorManager.getActiveEditor function in editor

To help you get started, we’ve selected a few editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adobe / brackets / src / LiveDevelopment / LiveDevelopment.js View on Github external
_openDeferred.done(function () {
            // Setup activeEditorChange event listener so that we can track cursor positions in
            // CSS preprocessor files and perform live preview highlighting on all elements with
            // the current selector in the preprocessor file.
            EditorManager.on("activeEditorChange", onActiveEditorChange);

            // Explicitly trigger onActiveEditorChange so that live preview highlighting
            // can be set up for the preprocessor files.
            onActiveEditorChange(null, EditorManager.getActiveEditor(), null);
        });
    }
github adobe / brackets / src / editor / EditorStatusBar.js View on Github external
function _updateEditorOverwriteMode(event) {
        var editor = EditorManager.getActiveEditor(),
            newstate = !editor._codeMirror.state.overwrite;

        // update label with no transition
        _updateOverwriteLabel(event, editor, newstate, true);
        editor.toggleOverwrite(newstate);
    }
github adobe / brackets / src / editor / CodeHintManager.js View on Github external
current.on("keypress", _handleKeypressEvent);
            current.on("keyup",    _handleKeyupEvent);
            current.on("cursorActivity", _handleCursorActivity);
        }

        if (previous) {
            //Removing all old Handlers
            previous.off("editorChange", _handleChange);
            previous.off("keydown",  _handleKeydownEvent);
            previous.off("keypress", _handleKeypressEvent);
            previous.off("keyup",    _handleKeyupEvent);
            previous.off("cursorActivity", _handleCursorActivity);
        }
    }

    activeEditorChangeHandler(null, EditorManager.getActiveEditor(), null);

    EditorManager.on("activeEditorChange", activeEditorChangeHandler);
 
    // Dismiss code hints before executing any command other than showing code hints since the command
    // may make the current hinting session irrevalent after execution.
    // For example, when the user hits Ctrl+K to open Quick Doc, it is
    // pointless to keep the hint list since the user wants to view the Quick Doc
    CommandManager.on("beforeExecuteCommand", function (event, commandId) {
        if (commandId !== Commands.SHOW_CODE_HINTS) {
            _endSession();
        }
    });

    CommandManager.register(Strings.CMD_SHOW_CODE_HINTS, Commands.SHOW_CODE_HINTS, _startNewSession);

    exports._getCodeHintList        = _getCodeHintList;
github adobe / brackets / src / features / ParameterHintsManager.js View on Github external
AppInit.appReady(function () {
        CommandManager.register(Strings.CMD_SHOW_PARAMETER_HINT, SHOW_PARAMETER_HINT_CMD_ID, handleShowParameterHint);

        // Add the menu items
        var menu = Menus.getMenu(Menus.AppMenuBar.EDIT_MENU);
        if (menu) {
            menu.addMenuItem(SHOW_PARAMETER_HINT_CMD_ID, KeyboardPrefs.showParameterHint, Menus.AFTER, Commands.SHOW_CODE_HINTS);
        }
        // Create the function hint container
        $hintContainer = $(hintContainerHTML).appendTo($("body"));
        $hintContent = $hintContainer.find(".function-hint-content-new");
        activeEditorChangeHandler(null, EditorManager.getActiveEditor(), null);

        EditorManager.on("activeEditorChange", activeEditorChangeHandler);

        CommandManager.on("beforeExecuteCommand", function (event, commandId) {
            if (commandId !== SHOW_PARAMETER_HINT_CMD_ID &&
                commandId !== Commands.SHOW_CODE_HINTS) {
                dismissHint();
            }
        });
    });
github adobe / brackets / src / LiveDevelopment / transports / WebSocketTransport.js View on Github external
WebSocketTransportDomain.on("fetch-code-text-message", function (obj, message) {
        console.log("WebSocketTransport - event - message" + " - " + message);
        var editor = EditorManager.getActiveEditor(),
            position = HTMLInstrumentation.getPositionFromTagId(editor, parseInt(message, 10));
        if (position) {
            editor.setCursorPos(position.line, position.ch, true);
        }
    });
github symbiose / symbiose / usr / lib / brackets / src / search / FindReplace.js View on Github external
function _replace() {
        var editor = EditorManager.getActiveEditor();
        if (editor) {
            replace(editor);
        }
    }
github adobe / brackets / src / search / FindReplace.js View on Github external
function _expandWordAndAddNextToSelection(editor, removePrimary) {
        editor = editor || EditorManager.getActiveEditor();
        if (!editor) {
            return;
        }

        var selections = editor.getSelections(),
            primarySel,
            primaryIndex,
            searchText,
            added = false;

        _.each(selections, function (sel, index) {
            var isEmpty = (CodeMirror.cmpPos(sel.start, sel.end) === 0);
            if (sel.primary) {
                primarySel = sel;
                primaryIndex = index;
                if (!isEmpty) {
github symbiose / symbiose / usr / lib / brackets / src / document / DocumentCommandHandlers.js View on Github external
function _configureEditorAndResolve() {
                var editor = EditorManager.getActiveEditor();
                if (editor) {
                    if (settings) {
                        editor.setCursorPos(settings.cursorPos);
                        editor.setSelection(settings.selection.start, settings.selection.end);
                        editor.setScrollPos(settings.scrollPos.x, settings.scrollPos.y);
                    }
                }
                result.resolve(newFile);
            }
github adobe / brackets / src / features / FindReferencesManager.js View on Github external
function setMenuItemStateForLanguage(languageId) {
        CommandManager.get(Commands.CMD_FIND_ALL_REFERENCES).setEnabled(false);
        if (!languageId) {
            var editor = EditorManager.getActiveEditor();
            if (editor) {
                languageId = LanguageManager.getLanguageForPath(editor.document.file._path).getId();
            }
        }
        var enabledProviders = _providerRegistrationHandler.getProvidersForLanguageId(languageId),
            referencesProvider;

        enabledProviders.some(function (item, index) {
            if (item.provider.hasReferences()) {
                referencesProvider = item.provider;
                return true;
            }
        });
        if (referencesProvider) {
            CommandManager.get(Commands.CMD_FIND_ALL_REFERENCES).setEnabled(true);
        }
github adobe / brackets / src / editor / EditorStatusBar.js View on Github external
function _toggleIndentType() {
        var current = EditorManager.getActiveEditor(),
            fullPath = current && current.document.file.fullPath;

        Editor.setUseTabChar(!Editor.getUseTabChar(fullPath), fullPath);
        _updateIndentType(fullPath);
        _updateIndentSize(fullPath);
    }