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
|
|
|
|
2016-07-08 08:26:02 +03:00
|
|
|
#include "mozilla/EditorController.h"
|
2014-12-02 08:07:42 +03:00
|
|
|
|
2016-06-24 05:45:22 +03:00
|
|
|
#include "EditorCommands.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "mozilla/mozalloc.h"
|
|
|
|
#include "nsDebug.h"
|
|
|
|
#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;
|
|
|
|
|
2016-07-08 08:26:02 +03:00
|
|
|
namespace mozilla {
|
2000-02-16 04:37:12 +03:00
|
|
|
|
2016-07-08 08:26:02 +03:00
|
|
|
#define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName) \
|
|
|
|
{ \
|
|
|
|
_cmdClass* theCmd = new _cmdClass(); \
|
|
|
|
NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY); \
|
|
|
|
aCommandTable->RegisterCommand( \
|
|
|
|
_cmdName, \
|
|
|
|
static_cast<nsIControllerCommand *>(theCmd)); \
|
2000-02-16 04:37:12 +03:00
|
|
|
}
|
|
|
|
|
2016-07-08 08:26:02 +03:00
|
|
|
#define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \
|
|
|
|
{ \
|
|
|
|
_cmdClass* theCmd = new _cmdClass(); \
|
|
|
|
NS_ENSURE_TRUE(theCmd, NS_ERROR_OUT_OF_MEMORY); \
|
|
|
|
aCommandTable->RegisterCommand( \
|
|
|
|
_cmdName, \
|
|
|
|
static_cast<nsIControllerCommand *>(theCmd));
|
|
|
|
|
|
|
|
#define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName) \
|
|
|
|
aCommandTable->RegisterCommand( \
|
|
|
|
_cmdName, \
|
|
|
|
static_cast<nsIControllerCommand *>(theCmd));
|
|
|
|
|
|
|
|
#define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName) \
|
|
|
|
aCommandTable->RegisterCommand( \
|
|
|
|
_cmdName, \
|
|
|
|
static_cast<nsIControllerCommand *>(theCmd)); \
|
2000-02-16 04:37:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2016-07-08 08:26:02 +03:00
|
|
|
nsresult
|
|
|
|
EditorController::RegisterEditingCommands(
|
|
|
|
nsIControllerCommandTable* aCommandTable)
|
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
|
|
|
|
2016-06-24 05:45:22 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(UndoCommand, "cmd_undo");
|
|
|
|
NS_REGISTER_ONE_COMMAND(RedoCommand, "cmd_redo");
|
|
|
|
NS_REGISTER_ONE_COMMAND(ClearUndoCommand, "cmd_clearUndo");
|
2000-02-16 04:37:12 +03:00
|
|
|
|
2016-06-24 05:45:22 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(CutCommand, "cmd_cut");
|
|
|
|
NS_REGISTER_ONE_COMMAND(CutOrDeleteCommand, "cmd_cutOrDelete");
|
|
|
|
NS_REGISTER_ONE_COMMAND(CopyCommand, "cmd_copy");
|
|
|
|
NS_REGISTER_ONE_COMMAND(CopyOrDeleteCommand, "cmd_copyOrDelete");
|
|
|
|
NS_REGISTER_ONE_COMMAND(CopyAndCollapseToEndCommand,
|
2014-11-27 01:06:00 +03:00
|
|
|
"cmd_copyAndCollapseToEnd");
|
2016-06-24 05:45:22 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(SelectAllCommand, "cmd_selectAll");
|
2011-12-22 22:16:56 +04:00
|
|
|
|
2016-06-24 05:45:22 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(PasteCommand, "cmd_paste");
|
|
|
|
NS_REGISTER_ONE_COMMAND(PasteTransferableCommand, "cmd_pasteTransferable");
|
2010-01-11 04:45:45 +03:00
|
|
|
|
2016-06-24 05:45:22 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(SwitchTextDirectionCommand,
|
|
|
|
"cmd_switchTextDirection");
|
2011-12-22 22:16:56 +04:00
|
|
|
|
2016-06-24 05:45:22 +03:00
|
|
|
NS_REGISTER_FIRST_COMMAND(DeleteCommand, "cmd_delete");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(DeleteCommand, "cmd_deleteCharBackward");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(DeleteCommand, "cmd_deleteCharForward");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(DeleteCommand, "cmd_deleteWordBackward");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(DeleteCommand, "cmd_deleteWordForward");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(DeleteCommand, "cmd_deleteToBeginningOfLine");
|
|
|
|
NS_REGISTER_LAST_COMMAND(DeleteCommand, "cmd_deleteToEndOfLine");
|
2000-02-16 04:37:12 +03:00
|
|
|
|
2011-12-24 04:11:30 +04:00
|
|
|
// Insert content
|
2016-06-24 05:45:22 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(InsertPlaintextCommand, "cmd_insertText");
|
2016-08-21 16:33:07 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(InsertParagraphCommand, "cmd_insertParagraph");
|
|
|
|
NS_REGISTER_ONE_COMMAND(InsertLineBreakCommand, "cmd_insertLineBreak");
|
2016-06-24 05:45:22 +03:00
|
|
|
NS_REGISTER_ONE_COMMAND(PasteQuotationCommand, "cmd_pasteQuote");
|
2011-12-24 04:11:30 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2016-07-08 08:26:02 +03:00
|
|
|
nsresult
|
|
|
|
EditorController::RegisterEditorCommands(
|
|
|
|
nsIControllerCommandTable* aCommandTable)
|
2011-12-24 04:11:30 +04:00
|
|
|
{
|
|
|
|
// These are commands that will be used in text widgets only.
|
|
|
|
|
2016-06-24 05:45:22 +03:00
|
|
|
NS_REGISTER_FIRST_COMMAND(SelectionMoveCommands, "cmd_scrollTop");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_scrollBottom");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_moveTop");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_moveBottom");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectTop");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectBottom");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_lineNext");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_linePrevious");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectLineNext");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectLinePrevious");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_charPrevious");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_charNext");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectCharPrevious");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectCharNext");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_beginLine");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_endLine");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectBeginLine");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectEndLine");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_wordPrevious");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_wordNext");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectWordPrevious");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectWordNext");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_scrollPageUp");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_scrollPageDown");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_scrollLineUp");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_scrollLineDown");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_movePageUp");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_movePageDown");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectPageUp");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectPageDown");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_moveLeft");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_moveRight");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_moveUp");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_moveDown");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_moveLeft2");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_moveRight2");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_moveUp2");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_moveDown2");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectLeft");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectRight");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectUp");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectDown");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectLeft2");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectRight2");
|
|
|
|
NS_REGISTER_NEXT_COMMAND(SelectionMoveCommands, "cmd_selectUp2");
|
|
|
|
NS_REGISTER_LAST_COMMAND(SelectionMoveCommands, "cmd_selectDown2");
|
1999-12-15 06:26:29 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-07-08 08:26:02 +03:00
|
|
|
} // namespace mozilla
|