diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /editor/libeditor/EditorCommands.h | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'editor/libeditor/EditorCommands.h')
-rw-r--r-- | editor/libeditor/EditorCommands.h | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/editor/libeditor/EditorCommands.h b/editor/libeditor/EditorCommands.h new file mode 100644 index 000000000..d7dc27b94 --- /dev/null +++ b/editor/libeditor/EditorCommands.h @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. */ + +#ifndef EditorCommands_h_ +#define EditorCommands_h_ + +#include "nsIControllerCommand.h" +#include "nsISupportsImpl.h" +#include "nscore.h" + +class nsICommandParams; +class nsISupports; + +namespace mozilla { + +/** + * This is a virtual base class for commands registered with the editor + * controller. Note that such commands can be shared by more than on editor + * instance, so MUST be stateless. Any state must be stored via the refCon + * (an nsIEditor). + */ + +class EditorCommandBase : public nsIControllerCommand +{ +public: + EditorCommandBase(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD IsCommandEnabled(const char* aCommandName, + nsISupports* aCommandRefCon, + bool* aIsEnabled) override = 0; + NS_IMETHOD DoCommand(const char* aCommandName, + nsISupports* aCommandRefCon) override = 0; + +protected: + virtual ~EditorCommandBase() {} +}; + + +#define NS_DECL_EDITOR_COMMAND(_cmd) \ +class _cmd final : public EditorCommandBase \ +{ \ +public: \ + NS_IMETHOD IsCommandEnabled(const char* aCommandName, \ + nsISupports* aCommandRefCon, \ + bool* aIsEnabled) override; \ + NS_IMETHOD DoCommand(const char* aCommandName, \ + nsISupports* aCommandRefCon) override; \ + NS_IMETHOD DoCommandParams(const char* aCommandName, \ + nsICommandParams* aParams, \ + nsISupports* aCommandRefCon) override; \ + NS_IMETHOD GetCommandStateParams(const char* aCommandName, \ + nsICommandParams* aParams, \ + nsISupports* aCommandRefCon) override; \ +}; + +// basic editor commands +NS_DECL_EDITOR_COMMAND(UndoCommand) +NS_DECL_EDITOR_COMMAND(RedoCommand) +NS_DECL_EDITOR_COMMAND(ClearUndoCommand) + +NS_DECL_EDITOR_COMMAND(CutCommand) +NS_DECL_EDITOR_COMMAND(CutOrDeleteCommand) +NS_DECL_EDITOR_COMMAND(CopyCommand) +NS_DECL_EDITOR_COMMAND(CopyOrDeleteCommand) +NS_DECL_EDITOR_COMMAND(CopyAndCollapseToEndCommand) +NS_DECL_EDITOR_COMMAND(PasteCommand) +NS_DECL_EDITOR_COMMAND(PasteTransferableCommand) +NS_DECL_EDITOR_COMMAND(SwitchTextDirectionCommand) +NS_DECL_EDITOR_COMMAND(DeleteCommand) +NS_DECL_EDITOR_COMMAND(SelectAllCommand) + +NS_DECL_EDITOR_COMMAND(SelectionMoveCommands) + +// Insert content commands +NS_DECL_EDITOR_COMMAND(InsertPlaintextCommand) +NS_DECL_EDITOR_COMMAND(InsertParagraphCommand) +NS_DECL_EDITOR_COMMAND(InsertLineBreakCommand) +NS_DECL_EDITOR_COMMAND(PasteQuotationCommand) + + +#if 0 +// template for new command +NS_IMETHODIMP +FooCommand::IsCommandEnabled(const char* aCommandName, + nsISupports* aCommandRefCon, + bool* aIsEnabled) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +FooCommand::DoCommand(const char* aCommandName, + const nsAString& aCommandParams, + nsISupports* aCommandRefCon) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +#endif + +} // namespace mozilla + +#endif // #ifndef EditorCommands_h_ |