2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-12-15 06:26:29 +03:00
|
|
|
|
2014-12-02 08:07:42 +03:00
|
|
|
#include "nsEditorController.h"
|
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "mozilla/mozalloc.h"
|
|
|
|
#include "nsDebug.h"
|
2000-02-16 04:37:12 +03:00
|
|
|
#include "nsEditorCommands.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsError.h"
|
2003-04-10 22:44:03 +04:00
|
|
|
#include "nsIControllerCommandTable.h"
|
2000-02-16 04:37:12 +03:00
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsIControllerCommand;
|
|
|
|
|
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(); \
|
2011-12-22 22:16:56 +04:00
|
|
|
NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY); \
|
|
|
|
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(); \
|
2011-12-22 22:16:56 +04:00
|
|
|
NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY); \
|
|
|
|
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) \
|
2011-12-22 22:16:56 +04:00
|
|
|
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) \
|
2011-12-22 22:16:56 +04:00
|
|
|
inCommandTable->RegisterCommand(_cmdName, \
|
2007-07-11 12:46:44 +04:00
|
|
|
static_cast<nsIControllerCommand *>(theCmd)); \
|
2000-02-16 04:37:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
2011-12-24 04:11:30 +04:00
|
|
|
nsresult nsEditorController::RegisterEditingCommands(nsIControllerCommandTable *inCommandTable)
|
2000-02-16 04:37:12 +03:00
|
|
|
{
|
|
|
|
// 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
|
2011-12-22 22:16:56 +04:00
|
|
|
|
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");
|
2014-11-27 01:06:00 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsCopyAndCollapseToEndCommand,
|
|
|
|
"cmd_copyAndCollapseToEnd");
|
2000-02-16 04:37:12 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsSelectAllCommand, "cmd_selectAll");
|
2011-12-22 22:16:56 +04:00
|
|
|
|
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");
|
2011-12-22 22:16:56 +04:00
|
|
|
|
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");
|
|
|
|
|
2011-12-24 04:11:30 +04:00
|
|
|
// Insert content
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsInsertPlaintextCommand, "cmd_insertText");
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsPasteQuotationCommand, "cmd_pasteQuote");
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static
|
|
|
|
nsresult nsEditorController::RegisterEditorCommands(nsIControllerCommandTable *inCommandTable)
|
|
|
|
{
|
|
|
|
// These are commands that will be used in text widgets only.
|
|
|
|
|
2000-02-16 04:37:12 +03:00
|
|
|
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");
|
2014-11-22 17:39:04 +03:00
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectPageDown");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveLeft");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveRight");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveUp");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveDown");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveLeft2");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveRight2");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveUp2");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveDown2");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectLeft");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectRight");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectUp");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectDown");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectLeft2");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectRight2");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectUp2");
|
|
|
|
NS_REGISTER_LAST_COMMAND(nsSelectionMoveCommands, "cmd_selectDown2");
|
1999-12-15 06:26:29 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|