Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Fix for issue #6084: Move Find items to different menu #7488

Merged
merged 10 commits into from
Apr 24, 2014
104 changes: 52 additions & 52 deletions src/base-config/keyboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,58 +80,6 @@
"displayKey": "Shift-Alt-↓"
}
],
"edit.find": [
"Ctrl-F"
],
"edit.findInFiles": [
"Ctrl-Shift-F"
],
"edit.findNext": [
{
"key": "F3"
},
{
"key": "Cmd-G",
"platform": "mac"
}
],
"edit.findPrevious": [
{
"key": "Shift-F3"
},
{
"key": "Cmd-Shift-G",
"platform": "mac"
}
],
"edit.findAllAndSelect": [
{
"key": "Alt-F3"
},
{
"key": "Cmd-Ctrl-G",
"platform": "mac"
}
],
"edit.addNextMatch": [
{
"key": "Ctrl-B"
}
],
"edit.skipCurrentMatch": [
{
"key": "Ctrl-Shift-B"
}
],
"edit.replace": [
{
"key": "Ctrl-H"
},
{
"key": "Cmd-Alt-F",
"platform": "mac"
}
],
"edit.indent": [
{
"key": "Ctrl-]"
Expand Down Expand Up @@ -197,6 +145,58 @@
"platform": "mac"
}
],
"cmd.find": [
"Ctrl-F"
],
"cmd.findInFiles": [
"Ctrl-Shift-F"
],
"cmd.findNext": [
{
"key": "F3"
},
{
"key": "Cmd-G",
"platform": "mac"
}
],
"cmd.findPrevious": [
{
"key": "Shift-F3"
},
{
"key": "Cmd-Shift-G",
"platform": "mac"
}
],
"cmd.findAllAndSelect": [
{
"key": "Alt-F3"
},
{
"key": "Cmd-Ctrl-G",
"platform": "mac"
}
],
"cmd.addNextMatch": [
{
"key": "Ctrl-B"
}
],
"cmd.skipCurrentMatch": [
{
"key": "Ctrl-Shift-B"
}
],
"cmd.replace": [
{
"key": "Ctrl-H"
},
{
"key": "Cmd-Alt-F",
"platform": "mac"
}
],
"view.hideSidebar": [
"Ctrl-Shift-H"
],
Expand Down
60 changes: 47 additions & 13 deletions src/command/Commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,30 @@
define(function (require, exports, module) {
"use strict";

var DeprecationWarning = require("utils/DeprecationWarning");

/**
* @private
* Create a deprecation warning and action for updated Command constants
* @param {!string} oldConstant
* @param {!string} newConstant
*/
function _deprecateCommand(oldConstant, newConstant) {
var warning = "Use Commands." + newConstant + " instead of Commands." + oldConstant,
newValue = exports[newConstant];

Object.defineProperty(exports, oldConstant, {
get: function () {
DeprecationWarning.deprecationWarning(warning, true);
return newValue;
}
});
}

/**
* List of constants for global command IDs.
*/

// FILE
exports.FILE_NEW_UNTITLED = "file.newDoc"; // DocumentCommandHandlers.js handleFileNew()
exports.FILE_NEW = "file.newFile"; // DocumentCommandHandlers.js handleFileNewInProject()
Expand Down Expand Up @@ -72,15 +92,6 @@ define(function (require, exports, module) {
exports.EDIT_SPLIT_SEL_INTO_LINES = "edit.splitSelIntoLines"; // EditorCommandHandlers.js splitSelIntoLines()
exports.EDIT_ADD_CUR_TO_NEXT_LINE = "edit.addCursorToNextLine"; // EditorCommandHandlers.js addCursorToNextLine()
exports.EDIT_ADD_CUR_TO_PREV_LINE = "edit.addCursorToPrevLine"; // EditorCommandHandlers.js addCursorToPrevLine()
exports.EDIT_FIND = "edit.find"; // FindReplace.js _launchFind()
exports.EDIT_FIND_IN_FILES = "edit.findInFiles"; // FindInFiles.js _doFindInFiles()
exports.EDIT_FIND_IN_SUBTREE = "edit.findInSubtree"; // FindInFiles.js _doFindInSubtree()
exports.EDIT_FIND_NEXT = "edit.findNext"; // FindReplace.js _findNext()
exports.EDIT_FIND_PREVIOUS = "edit.findPrevious"; // FindReplace.js _findPrevious()
exports.EDIT_FIND_ALL_AND_SELECT = "edit.findAllAndSelect"; // FindReplace.js _findAllAndSelect()
exports.EDIT_ADD_NEXT_MATCH = "edit.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection()
exports.EDIT_SKIP_CURRENT_MATCH = "edit.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch()
exports.EDIT_REPLACE = "edit.replace"; // FindReplace.js _replace()
exports.EDIT_INDENT = "edit.indent"; // EditorCommandHandlers.js indentText()
exports.EDIT_UNINDENT = "edit.unindent"; // EditorCommandHandlers.js unindentText()
exports.EDIT_DUPLICATE = "edit.duplicate"; // EditorCommandHandlers.js duplicateText()
Expand All @@ -93,7 +104,19 @@ define(function (require, exports, module) {
exports.EDIT_OPEN_LINE_BELOW = "edit.openLineBelow"; // EditorCommandHandlers.js openLineBelow()
exports.TOGGLE_CLOSE_BRACKETS = "edit.autoCloseBrackets"; // EditorOptionHandlers.js _getToggler()
exports.SHOW_CODE_HINTS = "edit.showCodeHints"; // CodeHintManager.js _startNewSession()


// FIND
exports.CMD_FIND = "cmd.find"; // FindReplace.js _launchFind()
exports.CMD_FIND_IN_FILES = "cmd.findInFiles"; // FindInFiles.js _doFindInFiles()
exports.CMD_FIND_IN_SELECTED = "cmd.findInSelected"; // FindInFiles.js _doFindInSubtree()
exports.CMD_FIND_IN_SUBTREE = "cmd.findInSubtree"; // FindInFiles.js _doFindInSubtree()
exports.CMD_FIND_NEXT = "cmd.findNext"; // FindReplace.js _findNext()
exports.CMD_FIND_PREVIOUS = "cmd.findPrevious"; // FindReplace.js _findPrevious()
exports.CMD_FIND_ALL_AND_SELECT = "cmd.findAllAndSelect"; // FindReplace.js _findAllAndSelect()
exports.CMD_ADD_NEXT_MATCH = "cmd.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection()
exports.CMD_SKIP_CURRENT_MATCH = "cmd.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch()
exports.CMD_REPLACE = "cmd.replace"; // FindReplace.js _replace()

// VIEW
exports.VIEW_HIDE_SIDEBAR = "view.hideSidebar"; // SidebarView.js toggle()
exports.VIEW_INCREASE_FONT_SIZE = "view.increaseFontSize"; // ViewCommandHandlers.js _handleIncreaseFontSize()
Expand Down Expand Up @@ -125,7 +148,7 @@ define(function (require, exports, module) {
exports.QUICK_EDIT_NEXT_MATCH = "navigate.nextMatch"; // MultiRangeInlineEditor.js _nextRange()
exports.QUICK_EDIT_PREV_MATCH = "navigate.previousMatch"; // MultiRangeInlineEditor.js _previousRange()
exports.CSS_QUICK_EDIT_NEW_RULE = "navigate.newRule"; // CSSInlineEditor.js _handleNewRule()

// HELP
exports.HELP_CHECK_FOR_UPDATE = "help.checkForUpdate"; // HelpCommandHandlers.js _handleCheckForUpdates()
exports.HELP_HOW_TO_USE_BRACKETS = "help.howToUseBrackets"; // HelpCommandHandlers.js _handleLinkMenuItem()
Expand All @@ -138,13 +161,24 @@ define(function (require, exports, module) {

// File shell callbacks - string must MATCH string in native code (appshell/command_callbacks.h)
exports.HELP_ABOUT = "help.about"; // HelpCommandHandlers.js _handleAboutDialog()

// APP
exports.APP_RELOAD = "app.reload"; // DocumentCommandHandlers.js handleReload()
exports.APP_RELOAD_WITHOUT_EXTS = "app.reload_without_exts"; // DocumentCommandHandlers.js handleReloadWithoutExts()

// File shell callbacks - string must MATCH string in native code (appshell/command_callbacks.h)
exports.APP_ABORT_QUIT = "app.abort_quit"; // DocumentCommandHandlers.js handleAbortQuit()
exports.APP_BEFORE_MENUPOPUP = "app.before_menupopup"; // DocumentCommandHandlers.js handleBeforeMenuPopup()

// DEPRECATED: Edit commands that were moved from the Edit Menu to the Find Menu
_deprecateCommand("EDIT_FIND", "CMD_FIND");
_deprecateCommand("EDIT_FIND_IN_SELECTED", "CMD_FIND_IN_SELECTED");
_deprecateCommand("EDIT_FIND_IN_SUBTREE", "CMD_FIND_IN_SUBTREE");
_deprecateCommand("EDIT_FIND_NEXT", "CMD_FIND_NEXT");
_deprecateCommand("EDIT_FIND_PREVIOUS", "CMD_FIND_PREVIOUS");
_deprecateCommand("EDIT_FIND_ALL_AND_SELECT", "CMD_FIND_ALL_AND_SELECT");
_deprecateCommand("EDIT_ADD_NEXT_MATCH", "CMD_ADD_NEXT_MATCH");
_deprecateCommand("EDIT_SKIP_CURRENT_MATCH", "CMD_SKIP_CURRENT_MATCH");
_deprecateCommand("EDIT_REPLACE", "CMD_REPLACE");
});

37 changes: 21 additions & 16 deletions src/command/DefaultMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ define(function (require, exports, module) {
menu.addMenuDivider();
menu.addMenuItem(Commands.FILE_QUIT);
}

/*
* Edit menu
*/
Expand All @@ -82,17 +82,6 @@ define(function (require, exports, module) {
menu.addMenuItem(Commands.EDIT_ADD_CUR_TO_PREV_LINE);
menu.addMenuItem(Commands.EDIT_ADD_CUR_TO_NEXT_LINE);
menu.addMenuDivider();
menu.addMenuItem(Commands.EDIT_FIND);
menu.addMenuItem(Commands.EDIT_FIND_IN_FILES);
menu.addMenuItem(Commands.EDIT_FIND_NEXT);
menu.addMenuItem(Commands.EDIT_FIND_PREVIOUS);
menu.addMenuItem(Commands.EDIT_FIND_ALL_AND_SELECT);
menu.addMenuItem(Commands.EDIT_ADD_NEXT_MATCH);
menu.addMenuItem(Commands.EDIT_SKIP_CURRENT_MATCH);

menu.addMenuDivider();
menu.addMenuItem(Commands.EDIT_REPLACE);
menu.addMenuDivider();
menu.addMenuItem(Commands.EDIT_INDENT);
menu.addMenuItem(Commands.EDIT_UNINDENT);
menu.addMenuItem(Commands.EDIT_DUPLICATE);
Expand All @@ -106,7 +95,23 @@ define(function (require, exports, module) {
menu.addMenuItem(Commands.SHOW_CODE_HINTS);
menu.addMenuDivider();
menu.addMenuItem(Commands.TOGGLE_CLOSE_BRACKETS);


/*
* Find menu
*/
menu = Menus.addMenu(Strings.FIND_MENU, Menus.AppMenuBar.FIND_MENU);
menu.addMenuItem(Commands.CMD_FIND);
menu.addMenuItem(Commands.CMD_FIND_NEXT);
menu.addMenuItem(Commands.CMD_FIND_PREVIOUS);
menu.addMenuItem(Commands.CMD_FIND_ALL_AND_SELECT);
menu.addMenuItem(Commands.CMD_ADD_NEXT_MATCH);
menu.addMenuItem(Commands.CMD_SKIP_CURRENT_MATCH);
menu.addMenuDivider();
menu.addMenuItem(Commands.CMD_FIND_IN_FILES);
menu.addMenuItem(Commands.CMD_FIND_IN_SELECTED);
menu.addMenuDivider();
menu.addMenuItem(Commands.CMD_REPLACE);

/*
* View menu
*/
Expand Down Expand Up @@ -146,7 +151,7 @@ define(function (require, exports, module) {
menu.addMenuItem(Commands.CSS_QUICK_EDIT_NEW_RULE);
menu.addMenuDivider();
menu.addMenuItem(Commands.TOGGLE_QUICK_DOCS);

/*
* Help menu
*/
Expand Down Expand Up @@ -199,7 +204,7 @@ define(function (require, exports, module) {
project_cmenu.addMenuItem(Commands.FILE_DELETE);
project_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS);
project_cmenu.addMenuDivider();
project_cmenu.addMenuItem(Commands.EDIT_FIND_IN_SUBTREE);
project_cmenu.addMenuItem(Commands.CMD_FIND_IN_SUBTREE);
project_cmenu.addMenuDivider();
project_cmenu.addMenuItem(Commands.FILE_REFRESH);

Expand All @@ -210,7 +215,7 @@ define(function (require, exports, module) {
working_set_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_FILE_TREE);
working_set_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS);
working_set_cmenu.addMenuDivider();
working_set_cmenu.addMenuItem(Commands.EDIT_FIND_IN_SUBTREE);
working_set_cmenu.addMenuItem(Commands.CMD_FIND_IN_SUBTREE);
working_set_cmenu.addMenuDivider();
working_set_cmenu.addMenuItem(Commands.FILE_CLOSE);

Expand Down
28 changes: 22 additions & 6 deletions src/command/Menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ define(function (require, exports, module) {
StringUtils = require("utils/StringUtils"),
CommandManager = require("command/CommandManager"),
PopUpManager = require("widgets/PopUpManager"),
ViewUtils = require("utils/ViewUtils");
ViewUtils = require("utils/ViewUtils"),
DeprecationWarning = require("utils/DeprecationWarning");

/**
* Brackets Application Menu Constants
Expand All @@ -46,6 +47,7 @@ define(function (require, exports, module) {
var AppMenuBar = {
FILE_MENU : "file-menu",
EDIT_MENU : "edit-menu",
FIND_MENU : "find-menu",
VIEW_MENU : "view-menu",
NAVIGATE_MENU : "navigate-menu",
HELP_MENU : "help-menu"
Expand Down Expand Up @@ -85,13 +87,19 @@ define(function (require, exports, module) {
EDIT_UNDO_REDO_COMMANDS: {sectionMarker: Commands.EDIT_UNDO},
EDIT_TEXT_COMMANDS: {sectionMarker: Commands.EDIT_CUT},
EDIT_SELECTION_COMMANDS: {sectionMarker: Commands.EDIT_SELECT_ALL},
EDIT_FIND_COMMANDS: {sectionMarker: Commands.EDIT_FIND},
EDIT_REPLACE_COMMANDS: {sectionMarker: Commands.EDIT_REPLACE},
EDIT_MODIFY_SELECTION: {sectionMarker: Commands.EDIT_INDENT},
EDIT_COMMENT_SELECTION: {sectionMarker: Commands.EDIT_LINE_COMMENT},
EDIT_CODE_HINTS_COMMANDS: {sectionMarker: Commands.SHOW_CODE_HINTS},
EDIT_TOGGLE_OPTIONS: {sectionMarker: Commands.TOGGLE_CLOSE_BRACKETS},


// DEPRECATED: Old Edit menu sections redirected to existing Edit menu section
EDIT_FIND_COMMANDS: {sectionMarker: Commands.TOGGLE_CLOSE_BRACKETS},
EDIT_REPLACE_COMMANDS: {sectionMarker: Commands.TOGGLE_CLOSE_BRACKETS},

FIND_FIND_COMMANDS: {sectionMarker: Commands.CMD_FIND},
FIND_FIND_IN_COMMANDS: {sectionMarker: Commands.CMD_FIND_IN_FILES},
FIND_REPLACE_COMMANDS: {sectionMarker: Commands.CMD_REPLACE},

VIEW_HIDESHOW_COMMANDS: {sectionMarker: Commands.VIEW_HIDE_SIDEBAR},
VIEW_FONTSIZE_COMMANDS: {sectionMarker: Commands.VIEW_INCREASE_FONT_SIZE},
VIEW_TOGGLE_OPTIONS: {sectionMarker: Commands.TOGGLE_ACTIVE_LINE},
Expand Down Expand Up @@ -359,7 +367,7 @@ define(function (require, exports, module) {
*/
Menu.prototype._getRelativeMenuItem = function (relativeID, position) {
var $relativeElement;

if (relativeID) {
if (position === FIRST_IN_SECTION || position === LAST_IN_SECTION) {
if (!relativeID.hasOwnProperty("sectionMarker")) {
Expand Down Expand Up @@ -547,7 +555,15 @@ define(function (require, exports, module) {
menuItem,
name,
commandID;


if (relativeID === MenuSection.EDIT_FIND_COMMANDS) {
DeprecationWarning.deprecationWarning("Add " + command + " Command to the Find Menu instead of the Edit Menu.", true);
DeprecationWarning.deprecationWarning("Use MenuSection.FIND_FIND_COMMANDS instead of MenuSection.EDIT_FIND_COMMANDS.", true);
} else if (relativeID === MenuSection.EDIT_REPLACE_COMMANDS) {
DeprecationWarning.deprecationWarning("Add " + command + " Command to the Find Menu instead of the Edit Menu.", true);
DeprecationWarning.deprecationWarning("Use MenuSection.FIND_REPLACE_COMMANDS instead of MenuSection.EDIT_REPLACE_COMMANDS.", true);
}

if (!command) {
console.error("addMenuItem(): missing required parameters: command");
return null;
Expand Down
Loading