-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-210: Registered find/replace commands and menu items.
Signed-off-by: Akos Kitta <[email protected]>
- Loading branch information
Showing
4 changed files
with
118 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright (C) 2017 TypeFox and others. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
import { MAIN_MENU_BAR, MenuContribution, MenuModelRegistry } from './menu'; | ||
import { CommandContribution, CommandRegistry } from './command'; | ||
import { injectable } from "inversify"; | ||
|
||
export namespace CommonCommands { | ||
export const EDIT_MENU = "2_edit"; | ||
export const EDIT_MENU_UNDO_GROUP = "1_undo/redo"; | ||
export const EDIT_MENU_FIND_REPLACE_GROUP = "2_find/replace"; | ||
export const EDIT_MENU_COPYPASTE_GROUP = "2_copy"; | ||
|
||
export const EDIT_CUT = 'edit_cut'; | ||
export const EDIT_COPY = 'edit_copy'; | ||
export const EDIT_PASTE = 'edit_paste'; | ||
|
||
export const EDIT_UNDO = 'undo'; | ||
export const EDIT_REDO = 'redo'; | ||
|
||
export const EDIT_FIND = 'actions.find'; | ||
export const EDIT_REPLACE = 'editor.action.startFindReplaceAction'; | ||
} | ||
|
||
@injectable() | ||
export class CommonMenuContribution implements MenuContribution { | ||
|
||
registerMenus(registry: MenuModelRegistry): void { | ||
// Explicitly register the Edit Submenu | ||
registry.registerSubmenu([MAIN_MENU_BAR], CommonCommands.EDIT_MENU, "Edit"); | ||
|
||
// Undo/Redo | ||
registry.registerMenuAction([ | ||
MAIN_MENU_BAR, | ||
CommonCommands.EDIT_MENU, | ||
CommonCommands.EDIT_MENU_UNDO_GROUP], { | ||
commandId: CommonCommands.EDIT_UNDO | ||
}); | ||
registry.registerMenuAction([ | ||
MAIN_MENU_BAR, | ||
CommonCommands.EDIT_MENU, | ||
CommonCommands.EDIT_MENU_UNDO_GROUP], { | ||
commandId: CommonCommands.EDIT_REDO | ||
}); | ||
// Find/Replace | ||
registry.registerMenuAction([ | ||
MAIN_MENU_BAR, | ||
CommonCommands.EDIT_MENU, | ||
CommonCommands.EDIT_MENU_FIND_REPLACE_GROUP], { | ||
commandId: CommonCommands.EDIT_FIND | ||
}); | ||
registry.registerMenuAction([ | ||
MAIN_MENU_BAR, | ||
CommonCommands.EDIT_MENU, | ||
CommonCommands.EDIT_MENU_FIND_REPLACE_GROUP], { | ||
commandId: CommonCommands.EDIT_REPLACE | ||
}); | ||
} | ||
|
||
} | ||
|
||
@injectable() | ||
export class CommonCommandContribution implements CommandContribution { | ||
|
||
registerCommands(commandRegistry: CommandRegistry): void { | ||
commandRegistry.registerCommand({ | ||
id: CommonCommands.EDIT_CUT, | ||
label: 'Cut' | ||
}); | ||
commandRegistry.registerCommand({ | ||
id: CommonCommands.EDIT_COPY, | ||
label: 'Copy', | ||
}); | ||
commandRegistry.registerCommand({ | ||
id: CommonCommands.EDIT_PASTE, | ||
label: 'Paste' | ||
}); | ||
commandRegistry.registerCommand({ | ||
id: CommonCommands.EDIT_UNDO, | ||
label: 'Undo' | ||
}); | ||
commandRegistry.registerCommand({ | ||
id: CommonCommands.EDIT_REDO, | ||
label: 'Redo' | ||
}); | ||
commandRegistry.registerCommand({ | ||
id: CommonCommands.EDIT_FIND, | ||
label: 'Find' | ||
}); | ||
commandRegistry.registerCommand({ | ||
id: CommonCommands.EDIT_REPLACE, | ||
label: 'Replace' | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters