2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:21:17 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-12-15 06:26:29 +03:00
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (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.mozilla.org/MPL/
|
1999-12-15 06:26:29 +03:00
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-12-15 06:26:29 +03:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-26 02:53:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-12-15 06:26:29 +03:00
|
|
|
*
|
2001-09-26 02:53:13 +04:00
|
|
|
* Contributor(s):
|
2000-01-11 23:49:15 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2000-07-28 14:14:22 +04:00
|
|
|
* Ryan Cassin <rcassin@supernova.org>
|
2001-09-26 02:53:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:21:17 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-26 02:53:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:21:17 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-26 02:53:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:21:17 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-26 02:53:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-12-15 06:26:29 +03:00
|
|
|
|
2001-04-05 03:48:03 +04:00
|
|
|
#include "nsString.h"
|
2000-02-16 04:37:12 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1999-12-15 06:26:29 +03:00
|
|
|
#include "nsEditorController.h"
|
2000-02-16 04:37:12 +03:00
|
|
|
#include "nsEditorCommands.h"
|
2003-04-10 22:44:03 +04:00
|
|
|
#include "nsIControllerCommandTable.h"
|
2000-02-16 04:37:12 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
2000-05-06 03:20:21 +04:00
|
|
|
#define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName) \
|
|
|
|
{ \
|
2010-07-05 13:42:18 +04:00
|
|
|
_cmdClass* theCmd = new _cmdClass(); \
|
2010-06-17 23:41:16 +04:00
|
|
|
NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY); \
|
2003-04-10 22:44:03 +04:00
|
|
|
rv = inCommandTable->RegisterCommand(_cmdName, \
|
2007-07-11 12:46:44 +04:00
|
|
|
static_cast<nsIControllerCommand *>(theCmd)); \
|
2000-02-16 04:37:12 +03:00
|
|
|
}
|
|
|
|
|
2000-05-06 03:20:21 +04:00
|
|
|
#define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \
|
|
|
|
{ \
|
2010-07-05 13:42:18 +04:00
|
|
|
_cmdClass* theCmd = new _cmdClass(); \
|
2010-06-17 23:41:16 +04:00
|
|
|
NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY); \
|
2003-04-10 22:44:03 +04:00
|
|
|
rv = inCommandTable->RegisterCommand(_cmdName, \
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsIControllerCommand *>(theCmd));
|
2000-05-06 03:20:21 +04:00
|
|
|
|
|
|
|
#define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName) \
|
2003-04-10 22:44:03 +04:00
|
|
|
rv = inCommandTable->RegisterCommand(_cmdName, \
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsIControllerCommand *>(theCmd));
|
2000-05-06 03:20:21 +04:00
|
|
|
|
|
|
|
#define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName) \
|
2003-04-10 22:44:03 +04:00
|
|
|
rv = inCommandTable->RegisterCommand(_cmdName, \
|
2007-07-11 12:46:44 +04:00
|
|
|
static_cast<nsIControllerCommand *>(theCmd)); \
|
2000-02-16 04:37:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
2003-04-10 22:44:03 +04:00
|
|
|
nsresult nsEditorController::RegisterEditorCommands(nsIControllerCommandTable *inCommandTable)
|
2000-02-16 04:37:12 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// now register all our commands
|
2000-05-02 01:49:52 +04:00
|
|
|
// These are commands that will be used in text widgets, and in composer
|
|
|
|
|
2000-02-16 04:37:12 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsUndoCommand, "cmd_undo");
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsRedoCommand, "cmd_redo");
|
2003-05-09 22:21:00 +04:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsClearUndoCommand, "cmd_clearUndo");
|
2000-02-16 04:37:12 +03:00
|
|
|
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsCutCommand, "cmd_cut");
|
2001-02-16 00:51:25 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsCutOrDeleteCommand, "cmd_cutOrDelete");
|
2000-02-16 04:37:12 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsCopyCommand, "cmd_copy");
|
2001-02-16 00:51:25 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsCopyOrDeleteCommand, "cmd_copyOrDelete");
|
2000-02-16 04:37:12 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsSelectAllCommand, "cmd_selectAll");
|
|
|
|
|
2000-05-02 01:49:52 +04:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsPasteCommand, "cmd_paste");
|
2010-01-11 04:45:45 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsPasteTransferableCommand, "cmd_pasteTransferable");
|
|
|
|
|
2005-01-26 04:40:30 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsSwitchTextDirectionCommand, "cmd_switchTextDirection");
|
2000-02-16 04:37:12 +03:00
|
|
|
|
|
|
|
NS_REGISTER_FIRST_COMMAND(nsDeleteCommand, "cmd_delete");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteCharBackward");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteCharForward");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteWordBackward");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteWordForward");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteToBeginningOfLine");
|
|
|
|
NS_REGISTER_LAST_COMMAND(nsDeleteCommand, "cmd_deleteToEndOfLine");
|
|
|
|
|
|
|
|
NS_REGISTER_FIRST_COMMAND(nsSelectionMoveCommands, "cmd_scrollTop");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollBottom");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveTop");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveBottom");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectTop");
|
2000-07-28 14:53:27 +04:00
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectBottom");
|
2000-02-16 04:37:12 +03:00
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_lineNext");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_linePrevious");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectLineNext");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectLinePrevious");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_charPrevious");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_charNext");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectCharPrevious");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectCharNext");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_beginLine");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_endLine");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectBeginLine");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectEndLine");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_wordPrevious");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_wordNext");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectWordPrevious");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectWordNext");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollPageUp");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollPageDown");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollLineUp");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollLineDown");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_movePageUp");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_movePageDown");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectPageUp");
|
|
|
|
NS_REGISTER_LAST_COMMAND(nsSelectionMoveCommands, "cmd_selectPageDown");
|
|
|
|
|
2002-11-13 02:03:27 +03:00
|
|
|
// Insert content
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsInsertPlaintextCommand, "cmd_insertText");
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsPasteQuotationCommand, "cmd_pasteQuote");
|
2000-02-16 04:37:12 +03:00
|
|
|
|
1999-12-15 06:26:29 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|