Bug 1247796. Use keyboardFocusIndicatorColor for ActiveBorder system color keyword...
[gecko.git] / editor / libeditor / nsEditorController.cpp
blob8941f25583f6b275832ea2782e826cc522b2b177
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsEditorController.h"
8 #include "mozilla/mozalloc.h"
9 #include "nsDebug.h"
10 #include "nsEditorCommands.h"
11 #include "nsError.h"
12 #include "nsIControllerCommandTable.h"
14 class nsIControllerCommand;
18 #define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName) \
19 { \
20 _cmdClass* theCmd = new _cmdClass(); \
21 NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY); \
22 inCommandTable->RegisterCommand(_cmdName, \
23 static_cast<nsIControllerCommand *>(theCmd)); \
26 #define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \
27 { \
28 _cmdClass* theCmd = new _cmdClass(); \
29 NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY); \
30 inCommandTable->RegisterCommand(_cmdName, \
31 static_cast<nsIControllerCommand *>(theCmd));
33 #define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName) \
34 inCommandTable->RegisterCommand(_cmdName, \
35 static_cast<nsIControllerCommand *>(theCmd));
37 #define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName) \
38 inCommandTable->RegisterCommand(_cmdName, \
39 static_cast<nsIControllerCommand *>(theCmd)); \
43 // static
44 nsresult nsEditorController::RegisterEditingCommands(nsIControllerCommandTable *inCommandTable)
46 // now register all our commands
47 // These are commands that will be used in text widgets, and in composer
49 NS_REGISTER_ONE_COMMAND(nsUndoCommand, "cmd_undo");
50 NS_REGISTER_ONE_COMMAND(nsRedoCommand, "cmd_redo");
51 NS_REGISTER_ONE_COMMAND(nsClearUndoCommand, "cmd_clearUndo");
53 NS_REGISTER_ONE_COMMAND(nsCutCommand, "cmd_cut");
54 NS_REGISTER_ONE_COMMAND(nsCutOrDeleteCommand, "cmd_cutOrDelete");
55 NS_REGISTER_ONE_COMMAND(nsCopyCommand, "cmd_copy");
56 NS_REGISTER_ONE_COMMAND(nsCopyOrDeleteCommand, "cmd_copyOrDelete");
57 NS_REGISTER_ONE_COMMAND(nsCopyAndCollapseToEndCommand,
58 "cmd_copyAndCollapseToEnd");
59 NS_REGISTER_ONE_COMMAND(nsSelectAllCommand, "cmd_selectAll");
61 NS_REGISTER_ONE_COMMAND(nsPasteCommand, "cmd_paste");
62 NS_REGISTER_ONE_COMMAND(nsPasteTransferableCommand, "cmd_pasteTransferable");
64 NS_REGISTER_ONE_COMMAND(nsSwitchTextDirectionCommand, "cmd_switchTextDirection");
66 NS_REGISTER_FIRST_COMMAND(nsDeleteCommand, "cmd_delete");
67 NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteCharBackward");
68 NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteCharForward");
69 NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteWordBackward");
70 NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteWordForward");
71 NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteToBeginningOfLine");
72 NS_REGISTER_LAST_COMMAND(nsDeleteCommand, "cmd_deleteToEndOfLine");
74 // Insert content
75 NS_REGISTER_ONE_COMMAND(nsInsertPlaintextCommand, "cmd_insertText");
76 NS_REGISTER_ONE_COMMAND(nsPasteQuotationCommand, "cmd_pasteQuote");
78 return NS_OK;
82 // static
83 nsresult nsEditorController::RegisterEditorCommands(nsIControllerCommandTable *inCommandTable)
85 // These are commands that will be used in text widgets only.
87 NS_REGISTER_FIRST_COMMAND(nsSelectionMoveCommands, "cmd_scrollTop");
88 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollBottom");
89 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveTop");
90 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveBottom");
91 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectTop");
92 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectBottom");
93 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_lineNext");
94 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_linePrevious");
95 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectLineNext");
96 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectLinePrevious");
97 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_charPrevious");
98 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_charNext");
99 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectCharPrevious");
100 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectCharNext");
101 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_beginLine");
102 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_endLine");
103 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectBeginLine");
104 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectEndLine");
105 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_wordPrevious");
106 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_wordNext");
107 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectWordPrevious");
108 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectWordNext");
109 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollPageUp");
110 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollPageDown");
111 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollLineUp");
112 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollLineDown");
113 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_movePageUp");
114 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_movePageDown");
115 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectPageUp");
116 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectPageDown");
117 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveLeft");
118 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveRight");
119 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveUp");
120 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveDown");
121 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveLeft2");
122 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveRight2");
123 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveUp2");
124 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveDown2");
125 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectLeft");
126 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectRight");
127 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectUp");
128 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectDown");
129 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectLeft2");
130 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectRight2");
131 NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectUp2");
132 NS_REGISTER_LAST_COMMAND(nsSelectionMoveCommands, "cmd_selectDown2");
134 return NS_OK;