зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1546839 - part 1: Change `enum Command` to `enum class Command` and drop "Command" prefix from each item r=smaug
If I remember correctly, `enum class` was not allowed when I added `enum Command`. Now, we can make it `enum class` for better type check at compile time. Differential Revision: https://phabricator.services.mozilla.com/D29169 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
cd530d2abf
Коммит
6c0c323d6f
|
@ -202,12 +202,12 @@ inline bool IsDataTransferAvailableOnHTMLEditor(EditorInputType aInputType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NS_DEFINE_COMMAND(aName, aCommandStr) , Command##aName
|
#define NS_DEFINE_COMMAND(aName, aCommandStr) , aName
|
||||||
#define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName) , Command##aName
|
#define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName) , aName
|
||||||
|
|
||||||
typedef int8_t CommandInt;
|
typedef int8_t CommandInt;
|
||||||
enum Command : CommandInt {
|
enum class Command : CommandInt {
|
||||||
CommandDoNothing
|
DoNothing
|
||||||
|
|
||||||
#include "mozilla/CommandList.h"
|
#include "mozilla/CommandList.h"
|
||||||
};
|
};
|
||||||
|
|
|
@ -76,17 +76,17 @@ const nsCString ToString(CodeNameIndex aCodeNameIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ToChar(Command aCommand) {
|
const char* ToChar(Command aCommand) {
|
||||||
if (aCommand == CommandDoNothing) {
|
if (aCommand == Command::DoNothing) {
|
||||||
return "CommandDoNothing";
|
return "CommandDoNothing";
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (aCommand) {
|
switch (aCommand) {
|
||||||
#define NS_DEFINE_COMMAND(aName, aCommandStr) \
|
#define NS_DEFINE_COMMAND(aName, aCommandStr) \
|
||||||
case Command##aName: \
|
case Command::aName: \
|
||||||
return "Command" #aName;
|
return "Command::" #aName;
|
||||||
#define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName) \
|
#define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName) \
|
||||||
case Command##aName: \
|
case Command::aName: \
|
||||||
return "Command" #aName;
|
return "Command::" #aName;
|
||||||
|
|
||||||
#include "mozilla/CommandList.h"
|
#include "mozilla/CommandList.h"
|
||||||
|
|
||||||
|
@ -1100,7 +1100,7 @@ uint32_t WidgetKeyboardEvent::GetFallbackKeyCodeOfPunctuationKey(
|
||||||
#define NS_DEFINE_COMMAND(aName, aCommandStr) , #aCommandStr
|
#define NS_DEFINE_COMMAND(aName, aCommandStr) , #aCommandStr
|
||||||
#define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName)
|
#define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName)
|
||||||
static const char* const kCommands[] = {
|
static const char* const kCommands[] = {
|
||||||
"" // CommandDoNothing
|
"" // DoNothing
|
||||||
#include "mozilla/CommandList.h"
|
#include "mozilla/CommandList.h"
|
||||||
};
|
};
|
||||||
#undef NS_DEFINE_COMMAND
|
#undef NS_DEFINE_COMMAND
|
||||||
|
@ -1108,7 +1108,7 @@ uint32_t WidgetKeyboardEvent::GetFallbackKeyCodeOfPunctuationKey(
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(static_cast<size_t>(aCommand) < ArrayLength(kCommands),
|
MOZ_RELEASE_ASSERT(static_cast<size_t>(aCommand) < ArrayLength(kCommands),
|
||||||
"Illegal command enumeration value");
|
"Illegal command enumeration value");
|
||||||
return kCommands[aCommand];
|
return kCommands[static_cast<CommandInt>(aCommand)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
|
|
||||||
typedef nsDataHashtable<nsPtrHashKey<struct objc_selector>, CommandInt>
|
typedef nsDataHashtable<nsPtrHashKey<struct objc_selector>, Command>
|
||||||
SelectorCommandHashtable;
|
SelectorCommandHashtable;
|
||||||
|
|
||||||
class NativeKeyBindings final {
|
class NativeKeyBindings final {
|
||||||
|
|
|
@ -70,24 +70,24 @@ void NativeKeyBindings::Init(NativeKeyBindingsType aType) {
|
||||||
// SEL_TO_COMMAND(centerSelectionInVisibleArea:, );
|
// SEL_TO_COMMAND(centerSelectionInVisibleArea:, );
|
||||||
// SEL_TO_COMMAND(changeCaseOfLetter:, );
|
// SEL_TO_COMMAND(changeCaseOfLetter:, );
|
||||||
// SEL_TO_COMMAND(complete:, );
|
// SEL_TO_COMMAND(complete:, );
|
||||||
SEL_TO_COMMAND(copy:, CommandCopy);
|
SEL_TO_COMMAND(copy:, Command::Copy);
|
||||||
// SEL_TO_COMMAND(copyFont:, );
|
// SEL_TO_COMMAND(copyFont:, );
|
||||||
// SEL_TO_COMMAND(copyRuler:, );
|
// SEL_TO_COMMAND(copyRuler:, );
|
||||||
SEL_TO_COMMAND(cut:, CommandCut);
|
SEL_TO_COMMAND(cut:, Command::Cut);
|
||||||
SEL_TO_COMMAND(delete:, CommandDelete);
|
SEL_TO_COMMAND(delete:, Command::Delete);
|
||||||
SEL_TO_COMMAND(deleteBackward:, CommandDeleteCharBackward);
|
SEL_TO_COMMAND(deleteBackward:, Command::DeleteCharBackward);
|
||||||
// SEL_TO_COMMAND(deleteBackwardByDecomposingPreviousCharacter:, );
|
// SEL_TO_COMMAND(deleteBackwardByDecomposingPreviousCharacter:, );
|
||||||
SEL_TO_COMMAND(deleteForward:, CommandDeleteCharForward);
|
SEL_TO_COMMAND(deleteForward:, Command::DeleteCharForward);
|
||||||
|
|
||||||
// TODO: deleteTo* selectors are also supposed to add text to a kill buffer
|
// TODO: deleteTo* selectors are also supposed to add text to a kill buffer
|
||||||
SEL_TO_COMMAND(deleteToBeginningOfLine:, CommandDeleteToBeginningOfLine);
|
SEL_TO_COMMAND(deleteToBeginningOfLine:, Command::DeleteToBeginningOfLine);
|
||||||
SEL_TO_COMMAND(deleteToBeginningOfParagraph:, CommandDeleteToBeginningOfLine);
|
SEL_TO_COMMAND(deleteToBeginningOfParagraph:, Command::DeleteToBeginningOfLine);
|
||||||
SEL_TO_COMMAND(deleteToEndOfLine:, CommandDeleteToEndOfLine);
|
SEL_TO_COMMAND(deleteToEndOfLine:, Command::DeleteToEndOfLine);
|
||||||
SEL_TO_COMMAND(deleteToEndOfParagraph:, CommandDeleteToEndOfLine);
|
SEL_TO_COMMAND(deleteToEndOfParagraph:, Command::DeleteToEndOfLine);
|
||||||
// SEL_TO_COMMAND(deleteToMark:, );
|
// SEL_TO_COMMAND(deleteToMark:, );
|
||||||
|
|
||||||
SEL_TO_COMMAND(deleteWordBackward:, CommandDeleteWordBackward);
|
SEL_TO_COMMAND(deleteWordBackward:, Command::DeleteWordBackward);
|
||||||
SEL_TO_COMMAND(deleteWordForward:, CommandDeleteWordForward);
|
SEL_TO_COMMAND(deleteWordForward:, Command::DeleteWordForward);
|
||||||
// SEL_TO_COMMAND(indent:, );
|
// SEL_TO_COMMAND(indent:, );
|
||||||
// SEL_TO_COMMAND(insertBacktab:, );
|
// SEL_TO_COMMAND(insertBacktab:, );
|
||||||
// SEL_TO_COMMAND(insertContainerBreak:, );
|
// SEL_TO_COMMAND(insertContainerBreak:, );
|
||||||
|
@ -100,69 +100,69 @@ void NativeKeyBindings::Init(NativeKeyBindingsType aType) {
|
||||||
// SEL_TO_COMMAND(insertDoubleQuoteIgnoringSubstitution:, );
|
// SEL_TO_COMMAND(insertDoubleQuoteIgnoringSubstitution:, );
|
||||||
// SEL_TO_COMMAND(insertSingleQuoteIgnoringSubstitution:, );
|
// SEL_TO_COMMAND(insertSingleQuoteIgnoringSubstitution:, );
|
||||||
// SEL_TO_COMMAND(lowercaseWord:, );
|
// SEL_TO_COMMAND(lowercaseWord:, );
|
||||||
SEL_TO_COMMAND(moveBackward:, CommandCharPrevious);
|
SEL_TO_COMMAND(moveBackward:, Command::CharPrevious);
|
||||||
SEL_TO_COMMAND(moveBackwardAndModifySelection:, CommandSelectCharPrevious);
|
SEL_TO_COMMAND(moveBackwardAndModifySelection:, Command::SelectCharPrevious);
|
||||||
if (aType == nsIWidget::NativeKeyBindingsForSingleLineEditor) {
|
if (aType == nsIWidget::NativeKeyBindingsForSingleLineEditor) {
|
||||||
SEL_TO_COMMAND(moveDown:, CommandEndLine);
|
SEL_TO_COMMAND(moveDown:, Command::EndLine);
|
||||||
} else {
|
} else {
|
||||||
SEL_TO_COMMAND(moveDown:, CommandLineNext);
|
SEL_TO_COMMAND(moveDown:, Command::LineNext);
|
||||||
}
|
}
|
||||||
SEL_TO_COMMAND(moveDownAndModifySelection:, CommandSelectLineNext);
|
SEL_TO_COMMAND(moveDownAndModifySelection:, Command::SelectLineNext);
|
||||||
SEL_TO_COMMAND(moveForward:, CommandCharNext);
|
SEL_TO_COMMAND(moveForward:, Command::CharNext);
|
||||||
SEL_TO_COMMAND(moveForwardAndModifySelection:, CommandSelectCharNext);
|
SEL_TO_COMMAND(moveForwardAndModifySelection:, Command::SelectCharNext);
|
||||||
SEL_TO_COMMAND(moveLeft:, CommandCharPrevious);
|
SEL_TO_COMMAND(moveLeft:, Command::CharPrevious);
|
||||||
SEL_TO_COMMAND(moveLeftAndModifySelection:, CommandSelectCharPrevious);
|
SEL_TO_COMMAND(moveLeftAndModifySelection:, Command::SelectCharPrevious);
|
||||||
SEL_TO_COMMAND(moveParagraphBackwardAndModifySelection:, CommandSelectBeginLine);
|
SEL_TO_COMMAND(moveParagraphBackwardAndModifySelection:, Command::SelectBeginLine);
|
||||||
SEL_TO_COMMAND(moveParagraphForwardAndModifySelection:, CommandSelectEndLine);
|
SEL_TO_COMMAND(moveParagraphForwardAndModifySelection:, Command::SelectEndLine);
|
||||||
SEL_TO_COMMAND(moveRight:, CommandCharNext);
|
SEL_TO_COMMAND(moveRight:, Command::CharNext);
|
||||||
SEL_TO_COMMAND(moveRightAndModifySelection:, CommandSelectCharNext);
|
SEL_TO_COMMAND(moveRightAndModifySelection:, Command::SelectCharNext);
|
||||||
SEL_TO_COMMAND(moveToBeginningOfDocument:, CommandMoveTop);
|
SEL_TO_COMMAND(moveToBeginningOfDocument:, Command::MoveTop);
|
||||||
SEL_TO_COMMAND(moveToBeginningOfDocumentAndModifySelection:, CommandSelectTop);
|
SEL_TO_COMMAND(moveToBeginningOfDocumentAndModifySelection:, Command::SelectTop);
|
||||||
SEL_TO_COMMAND(moveToBeginningOfLine:, CommandBeginLine);
|
SEL_TO_COMMAND(moveToBeginningOfLine:, Command::BeginLine);
|
||||||
SEL_TO_COMMAND(moveToBeginningOfLineAndModifySelection:, CommandSelectBeginLine);
|
SEL_TO_COMMAND(moveToBeginningOfLineAndModifySelection:, Command::SelectBeginLine);
|
||||||
SEL_TO_COMMAND(moveToBeginningOfParagraph:, CommandBeginLine);
|
SEL_TO_COMMAND(moveToBeginningOfParagraph:, Command::BeginLine);
|
||||||
SEL_TO_COMMAND(moveToBeginningOfParagraphAndModifySelection:, CommandSelectBeginLine);
|
SEL_TO_COMMAND(moveToBeginningOfParagraphAndModifySelection:, Command::SelectBeginLine);
|
||||||
SEL_TO_COMMAND(moveToEndOfDocument:, CommandMoveBottom);
|
SEL_TO_COMMAND(moveToEndOfDocument:, Command::MoveBottom);
|
||||||
SEL_TO_COMMAND(moveToEndOfDocumentAndModifySelection:, CommandSelectBottom);
|
SEL_TO_COMMAND(moveToEndOfDocumentAndModifySelection:, Command::SelectBottom);
|
||||||
SEL_TO_COMMAND(moveToEndOfLine:, CommandEndLine);
|
SEL_TO_COMMAND(moveToEndOfLine:, Command::EndLine);
|
||||||
SEL_TO_COMMAND(moveToEndOfLineAndModifySelection:, CommandSelectEndLine);
|
SEL_TO_COMMAND(moveToEndOfLineAndModifySelection:, Command::SelectEndLine);
|
||||||
SEL_TO_COMMAND(moveToEndOfParagraph:, CommandEndLine);
|
SEL_TO_COMMAND(moveToEndOfParagraph:, Command::EndLine);
|
||||||
SEL_TO_COMMAND(moveToEndOfParagraphAndModifySelection:, CommandSelectEndLine);
|
SEL_TO_COMMAND(moveToEndOfParagraphAndModifySelection:, Command::SelectEndLine);
|
||||||
SEL_TO_COMMAND(moveToLeftEndOfLine:, CommandBeginLine);
|
SEL_TO_COMMAND(moveToLeftEndOfLine:, Command::BeginLine);
|
||||||
SEL_TO_COMMAND(moveToLeftEndOfLineAndModifySelection:, CommandSelectBeginLine);
|
SEL_TO_COMMAND(moveToLeftEndOfLineAndModifySelection:, Command::SelectBeginLine);
|
||||||
SEL_TO_COMMAND(moveToRightEndOfLine:, CommandEndLine);
|
SEL_TO_COMMAND(moveToRightEndOfLine:, Command::EndLine);
|
||||||
SEL_TO_COMMAND(moveToRightEndOfLineAndModifySelection:, CommandSelectEndLine);
|
SEL_TO_COMMAND(moveToRightEndOfLineAndModifySelection:, Command::SelectEndLine);
|
||||||
if (aType == nsIWidget::NativeKeyBindingsForSingleLineEditor) {
|
if (aType == nsIWidget::NativeKeyBindingsForSingleLineEditor) {
|
||||||
SEL_TO_COMMAND(moveUp:, CommandBeginLine);
|
SEL_TO_COMMAND(moveUp:, Command::BeginLine);
|
||||||
} else {
|
} else {
|
||||||
SEL_TO_COMMAND(moveUp:, CommandLinePrevious);
|
SEL_TO_COMMAND(moveUp:, Command::LinePrevious);
|
||||||
}
|
}
|
||||||
SEL_TO_COMMAND(moveUpAndModifySelection:, CommandSelectLinePrevious);
|
SEL_TO_COMMAND(moveUpAndModifySelection:, Command::SelectLinePrevious);
|
||||||
SEL_TO_COMMAND(moveWordBackward:, CommandWordPrevious);
|
SEL_TO_COMMAND(moveWordBackward:, Command::WordPrevious);
|
||||||
SEL_TO_COMMAND(moveWordBackwardAndModifySelection:, CommandSelectWordPrevious);
|
SEL_TO_COMMAND(moveWordBackwardAndModifySelection:, Command::SelectWordPrevious);
|
||||||
SEL_TO_COMMAND(moveWordForward:, CommandWordNext);
|
SEL_TO_COMMAND(moveWordForward:, Command::WordNext);
|
||||||
SEL_TO_COMMAND(moveWordForwardAndModifySelection:, CommandSelectWordNext);
|
SEL_TO_COMMAND(moveWordForwardAndModifySelection:, Command::SelectWordNext);
|
||||||
SEL_TO_COMMAND(moveWordLeft:, CommandWordPrevious);
|
SEL_TO_COMMAND(moveWordLeft:, Command::WordPrevious);
|
||||||
SEL_TO_COMMAND(moveWordLeftAndModifySelection:, CommandSelectWordPrevious);
|
SEL_TO_COMMAND(moveWordLeftAndModifySelection:, Command::SelectWordPrevious);
|
||||||
SEL_TO_COMMAND(moveWordRight:, CommandWordNext);
|
SEL_TO_COMMAND(moveWordRight:, Command::WordNext);
|
||||||
SEL_TO_COMMAND(moveWordRightAndModifySelection:, CommandSelectWordNext);
|
SEL_TO_COMMAND(moveWordRightAndModifySelection:, Command::SelectWordNext);
|
||||||
SEL_TO_COMMAND(pageDown:, CommandMovePageDown);
|
SEL_TO_COMMAND(pageDown:, Command::MovePageDown);
|
||||||
SEL_TO_COMMAND(pageDownAndModifySelection:, CommandSelectPageDown);
|
SEL_TO_COMMAND(pageDownAndModifySelection:, Command::SelectPageDown);
|
||||||
SEL_TO_COMMAND(pageUp:, CommandMovePageUp);
|
SEL_TO_COMMAND(pageUp:, Command::MovePageUp);
|
||||||
SEL_TO_COMMAND(pageUpAndModifySelection:, CommandSelectPageUp);
|
SEL_TO_COMMAND(pageUpAndModifySelection:, Command::SelectPageUp);
|
||||||
SEL_TO_COMMAND(paste:, CommandPaste);
|
SEL_TO_COMMAND(paste:, Command::Paste);
|
||||||
// SEL_TO_COMMAND(pasteFont:, );
|
// SEL_TO_COMMAND(pasteFont:, );
|
||||||
// SEL_TO_COMMAND(pasteRuler:, );
|
// SEL_TO_COMMAND(pasteRuler:, );
|
||||||
SEL_TO_COMMAND(scrollLineDown:, CommandScrollLineDown);
|
SEL_TO_COMMAND(scrollLineDown:, Command::ScrollLineDown);
|
||||||
SEL_TO_COMMAND(scrollLineUp:, CommandScrollLineUp);
|
SEL_TO_COMMAND(scrollLineUp:, Command::ScrollLineUp);
|
||||||
SEL_TO_COMMAND(scrollPageDown:, CommandScrollPageDown);
|
SEL_TO_COMMAND(scrollPageDown:, Command::ScrollPageDown);
|
||||||
SEL_TO_COMMAND(scrollPageUp:, CommandScrollPageUp);
|
SEL_TO_COMMAND(scrollPageUp:, Command::ScrollPageUp);
|
||||||
SEL_TO_COMMAND(scrollToBeginningOfDocument:, CommandScrollTop);
|
SEL_TO_COMMAND(scrollToBeginningOfDocument:, Command::ScrollTop);
|
||||||
SEL_TO_COMMAND(scrollToEndOfDocument:, CommandScrollBottom);
|
SEL_TO_COMMAND(scrollToEndOfDocument:, Command::ScrollBottom);
|
||||||
SEL_TO_COMMAND(selectAll:, CommandSelectAll);
|
SEL_TO_COMMAND(selectAll:, Command::SelectAll);
|
||||||
// selectLine: is complex, see KeyDown
|
// selectLine: is complex, see KeyDown
|
||||||
if (aType == nsIWidget::NativeKeyBindingsForSingleLineEditor) {
|
if (aType == nsIWidget::NativeKeyBindingsForSingleLineEditor) {
|
||||||
SEL_TO_COMMAND(selectParagraph:, CommandSelectAll);
|
SEL_TO_COMMAND(selectParagraph:, Command::SelectAll);
|
||||||
}
|
}
|
||||||
// SEL_TO_COMMAND(selectToMark:, );
|
// SEL_TO_COMMAND(selectToMark:, );
|
||||||
// selectWord: is complex, see KeyDown
|
// selectWord: is complex, see KeyDown
|
||||||
|
@ -220,23 +220,22 @@ void NativeKeyBindings::GetEditCommands(const WidgetKeyboardEvent& aEvent,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to find a simple mapping in the hashtable
|
// Try to find a simple mapping in the hashtable
|
||||||
CommandInt geckoCommand =
|
Command geckoCommand = Command::DoNothing;
|
||||||
mSelectorToCommand.Get(reinterpret_cast<struct objc_selector*>(selector));
|
if (mSelectorToCommand.Get(reinterpret_cast<struct objc_selector*>(selector), &geckoCommand) &&
|
||||||
|
geckoCommand != Command::DoNothing) {
|
||||||
if (geckoCommand) {
|
aCommands.AppendElement(static_cast<CommandInt>(geckoCommand));
|
||||||
aCommands.AppendElement(geckoCommand);
|
|
||||||
} else if (selector == @selector(selectLine:)) {
|
} else if (selector == @selector(selectLine:)) {
|
||||||
// This is functional, but Cocoa's version is direction-less in that
|
// This is functional, but Cocoa's version is direction-less in that
|
||||||
// selection direction is not determined until some future directed action
|
// selection direction is not determined until some future directed action
|
||||||
// is taken. See bug 282097, comment 79 for more details.
|
// is taken. See bug 282097, comment 79 for more details.
|
||||||
aCommands.AppendElement(CommandBeginLine);
|
aCommands.AppendElement(static_cast<CommandInt>(Command::BeginLine));
|
||||||
aCommands.AppendElement(CommandSelectEndLine);
|
aCommands.AppendElement(static_cast<CommandInt>(Command::SelectEndLine));
|
||||||
} else if (selector == @selector(selectWord:)) {
|
} else if (selector == @selector(selectWord:)) {
|
||||||
// This is functional, but Cocoa's version is direction-less in that
|
// This is functional, but Cocoa's version is direction-less in that
|
||||||
// selection direction is not determined until some future directed action
|
// selection direction is not determined until some future directed action
|
||||||
// is taken. See bug 282097, comment 79 for more details.
|
// is taken. See bug 282097, comment 79 for more details.
|
||||||
aCommands.AppendElement(CommandWordPrevious);
|
aCommands.AppendElement(static_cast<CommandInt>(Command::WordPrevious));
|
||||||
aCommands.AppendElement(CommandSelectWordNext);
|
aCommands.AppendElement(static_cast<CommandInt>(Command::SelectWordNext));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -612,89 +612,89 @@ class TextInputHandlerBase : public TextEventDispatcherListener {
|
||||||
Modifiers modifiers = nsCocoaUtils::ModifiersForEvent(mKeyEvent) &
|
Modifiers modifiers = nsCocoaUtils::ModifiersForEvent(mKeyEvent) &
|
||||||
(MODIFIER_SHIFT | MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
(MODIFIER_SHIFT | MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
||||||
switch (aCommand) {
|
switch (aCommand) {
|
||||||
case CommandInsertLineBreak:
|
case Command::InsertLineBreak:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_Enter && modifiers == MODIFIER_CONTROL;
|
return keyNameIndex == KEY_NAME_INDEX_Enter && modifiers == MODIFIER_CONTROL;
|
||||||
case CommandInsertParagraph:
|
case Command::InsertParagraph:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_Enter && modifiers == MODIFIER_NONE;
|
return keyNameIndex == KEY_NAME_INDEX_Enter && modifiers == MODIFIER_NONE;
|
||||||
case CommandDeleteCharBackward:
|
case Command::DeleteCharBackward:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_Backspace && modifiers == MODIFIER_NONE;
|
return keyNameIndex == KEY_NAME_INDEX_Backspace && modifiers == MODIFIER_NONE;
|
||||||
case CommandDeleteToBeginningOfLine:
|
case Command::DeleteToBeginningOfLine:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_Backspace && modifiers == MODIFIER_META;
|
return keyNameIndex == KEY_NAME_INDEX_Backspace && modifiers == MODIFIER_META;
|
||||||
case CommandDeleteWordBackward:
|
case Command::DeleteWordBackward:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_Backspace && modifiers == MODIFIER_ALT;
|
return keyNameIndex == KEY_NAME_INDEX_Backspace && modifiers == MODIFIER_ALT;
|
||||||
case CommandDeleteCharForward:
|
case Command::DeleteCharForward:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_Delete && modifiers == MODIFIER_NONE;
|
return keyNameIndex == KEY_NAME_INDEX_Delete && modifiers == MODIFIER_NONE;
|
||||||
case CommandDeleteWordForward:
|
case Command::DeleteWordForward:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_Delete && modifiers == MODIFIER_ALT;
|
return keyNameIndex == KEY_NAME_INDEX_Delete && modifiers == MODIFIER_ALT;
|
||||||
case CommandInsertTab:
|
case Command::InsertTab:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_Tab && modifiers == MODIFIER_NONE;
|
return keyNameIndex == KEY_NAME_INDEX_Tab && modifiers == MODIFIER_NONE;
|
||||||
case CommandInsertBacktab:
|
case Command::InsertBacktab:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_Tab && modifiers == MODIFIER_SHIFT;
|
return keyNameIndex == KEY_NAME_INDEX_Tab && modifiers == MODIFIER_SHIFT;
|
||||||
case CommandCharNext:
|
case Command::CharNext:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowRight && modifiers == MODIFIER_NONE;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowRight && modifiers == MODIFIER_NONE;
|
||||||
case CommandSelectCharNext:
|
case Command::SelectCharNext:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowRight && modifiers == MODIFIER_SHIFT;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowRight && modifiers == MODIFIER_SHIFT;
|
||||||
case CommandWordNext:
|
case Command::WordNext:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowRight && modifiers == MODIFIER_ALT;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowRight && modifiers == MODIFIER_ALT;
|
||||||
case CommandSelectWordNext:
|
case Command::SelectWordNext:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowRight &&
|
return keyNameIndex == KEY_NAME_INDEX_ArrowRight &&
|
||||||
modifiers == (MODIFIER_ALT | MODIFIER_SHIFT);
|
modifiers == (MODIFIER_ALT | MODIFIER_SHIFT);
|
||||||
case CommandEndLine:
|
case Command::EndLine:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowRight && modifiers == MODIFIER_META;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowRight && modifiers == MODIFIER_META;
|
||||||
case CommandSelectEndLine:
|
case Command::SelectEndLine:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowRight &&
|
return keyNameIndex == KEY_NAME_INDEX_ArrowRight &&
|
||||||
modifiers == (MODIFIER_META | MODIFIER_SHIFT);
|
modifiers == (MODIFIER_META | MODIFIER_SHIFT);
|
||||||
case CommandCharPrevious:
|
case Command::CharPrevious:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft && modifiers == MODIFIER_NONE;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft && modifiers == MODIFIER_NONE;
|
||||||
case CommandSelectCharPrevious:
|
case Command::SelectCharPrevious:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft && modifiers == MODIFIER_SHIFT;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft && modifiers == MODIFIER_SHIFT;
|
||||||
case CommandWordPrevious:
|
case Command::WordPrevious:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft && modifiers == MODIFIER_ALT;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft && modifiers == MODIFIER_ALT;
|
||||||
case CommandSelectWordPrevious:
|
case Command::SelectWordPrevious:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft &&
|
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft &&
|
||||||
modifiers == (MODIFIER_ALT | MODIFIER_SHIFT);
|
modifiers == (MODIFIER_ALT | MODIFIER_SHIFT);
|
||||||
case CommandBeginLine:
|
case Command::BeginLine:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft && modifiers == MODIFIER_META;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft && modifiers == MODIFIER_META;
|
||||||
case CommandSelectBeginLine:
|
case Command::SelectBeginLine:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft &&
|
return keyNameIndex == KEY_NAME_INDEX_ArrowLeft &&
|
||||||
modifiers == (MODIFIER_META | MODIFIER_SHIFT);
|
modifiers == (MODIFIER_META | MODIFIER_SHIFT);
|
||||||
case CommandLinePrevious:
|
case Command::LinePrevious:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowUp && modifiers == MODIFIER_NONE;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowUp && modifiers == MODIFIER_NONE;
|
||||||
case CommandSelectLinePrevious:
|
case Command::SelectLinePrevious:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowUp && modifiers == MODIFIER_SHIFT;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowUp && modifiers == MODIFIER_SHIFT;
|
||||||
case CommandMoveTop:
|
case Command::MoveTop:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowUp && modifiers == MODIFIER_META;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowUp && modifiers == MODIFIER_META;
|
||||||
case CommandSelectTop:
|
case Command::SelectTop:
|
||||||
return (keyNameIndex == KEY_NAME_INDEX_ArrowUp &&
|
return (keyNameIndex == KEY_NAME_INDEX_ArrowUp &&
|
||||||
modifiers == (MODIFIER_META | MODIFIER_SHIFT)) ||
|
modifiers == (MODIFIER_META | MODIFIER_SHIFT)) ||
|
||||||
(keyNameIndex == KEY_NAME_INDEX_Home && modifiers == MODIFIER_SHIFT);
|
(keyNameIndex == KEY_NAME_INDEX_Home && modifiers == MODIFIER_SHIFT);
|
||||||
case CommandLineNext:
|
case Command::LineNext:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowDown && modifiers == MODIFIER_NONE;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowDown && modifiers == MODIFIER_NONE;
|
||||||
case CommandSelectLineNext:
|
case Command::SelectLineNext:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowDown && modifiers == MODIFIER_SHIFT;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowDown && modifiers == MODIFIER_SHIFT;
|
||||||
case CommandMoveBottom:
|
case Command::MoveBottom:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_ArrowDown && modifiers == MODIFIER_META;
|
return keyNameIndex == KEY_NAME_INDEX_ArrowDown && modifiers == MODIFIER_META;
|
||||||
case CommandSelectBottom:
|
case Command::SelectBottom:
|
||||||
return (keyNameIndex == KEY_NAME_INDEX_ArrowDown &&
|
return (keyNameIndex == KEY_NAME_INDEX_ArrowDown &&
|
||||||
modifiers == (MODIFIER_META | MODIFIER_SHIFT)) ||
|
modifiers == (MODIFIER_META | MODIFIER_SHIFT)) ||
|
||||||
(keyNameIndex == KEY_NAME_INDEX_End && modifiers == MODIFIER_SHIFT);
|
(keyNameIndex == KEY_NAME_INDEX_End && modifiers == MODIFIER_SHIFT);
|
||||||
case CommandScrollPageUp:
|
case Command::ScrollPageUp:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_PageUp && modifiers == MODIFIER_NONE;
|
return keyNameIndex == KEY_NAME_INDEX_PageUp && modifiers == MODIFIER_NONE;
|
||||||
case CommandSelectPageUp:
|
case Command::SelectPageUp:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_PageUp && modifiers == MODIFIER_SHIFT;
|
return keyNameIndex == KEY_NAME_INDEX_PageUp && modifiers == MODIFIER_SHIFT;
|
||||||
case CommandScrollPageDown:
|
case Command::ScrollPageDown:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_PageDown && modifiers == MODIFIER_NONE;
|
return keyNameIndex == KEY_NAME_INDEX_PageDown && modifiers == MODIFIER_NONE;
|
||||||
case CommandSelectPageDown:
|
case Command::SelectPageDown:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_PageDown && modifiers == MODIFIER_SHIFT;
|
return keyNameIndex == KEY_NAME_INDEX_PageDown && modifiers == MODIFIER_SHIFT;
|
||||||
case CommandScrollBottom:
|
case Command::ScrollBottom:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_End && modifiers == MODIFIER_NONE;
|
return keyNameIndex == KEY_NAME_INDEX_End && modifiers == MODIFIER_NONE;
|
||||||
case CommandScrollTop:
|
case Command::ScrollTop:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_Home && modifiers == MODIFIER_NONE;
|
return keyNameIndex == KEY_NAME_INDEX_Home && modifiers == MODIFIER_NONE;
|
||||||
case CommandCancelOperation:
|
case Command::CancelOperation:
|
||||||
return (keyNameIndex == KEY_NAME_INDEX_Escape &&
|
return (keyNameIndex == KEY_NAME_INDEX_Escape &&
|
||||||
(modifiers == MODIFIER_NONE || modifiers == MODIFIER_SHIFT)) ||
|
(modifiers == MODIFIER_NONE || modifiers == MODIFIER_SHIFT)) ||
|
||||||
([mKeyEvent keyCode] == kVK_ANSI_Period && modifiers == MODIFIER_META);
|
([mKeyEvent keyCode] == kVK_ANSI_Period && modifiers == MODIFIER_META);
|
||||||
case CommandComplete:
|
case Command::Complete:
|
||||||
return keyNameIndex == KEY_NAME_INDEX_Escape &&
|
return keyNameIndex == KEY_NAME_INDEX_Escape &&
|
||||||
(modifiers == MODIFIER_ALT || modifiers == (MODIFIER_ALT | MODIFIER_SHIFT));
|
(modifiers == MODIFIER_ALT || modifiers == (MODIFIER_ALT | MODIFIER_SHIFT));
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -2517,8 +2517,8 @@ bool TextInputHandler::HandleCommand(Command aCommand) {
|
||||||
// the command.
|
// the command.
|
||||||
if (IsIMEComposing()) {
|
if (IsIMEComposing()) {
|
||||||
switch (aCommand) {
|
switch (aCommand) {
|
||||||
case CommandInsertLineBreak:
|
case Command::InsertLineBreak:
|
||||||
case CommandInsertParagraph: {
|
case Command::InsertParagraph: {
|
||||||
// Insert '\n' as committing composition.
|
// Insert '\n' as committing composition.
|
||||||
// Otherwise, we need to dispatch keypress event because HTMLEditor
|
// Otherwise, we need to dispatch keypress event because HTMLEditor
|
||||||
// doesn't treat "\n" in composition string as a line break unless
|
// doesn't treat "\n" in composition string as a line break unless
|
||||||
|
@ -2533,48 +2533,48 @@ bool TextInputHandler::HandleCommand(Command aCommand) {
|
||||||
[lineBreaker release];
|
[lineBreaker release];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case CommandDeleteCharBackward:
|
case Command::DeleteCharBackward:
|
||||||
case CommandDeleteCharForward:
|
case Command::DeleteCharForward:
|
||||||
case CommandDeleteToBeginningOfLine:
|
case Command::DeleteToBeginningOfLine:
|
||||||
case CommandDeleteWordBackward:
|
case Command::DeleteWordBackward:
|
||||||
case CommandDeleteWordForward:
|
case Command::DeleteWordForward:
|
||||||
// Don't remove any contents during composition.
|
// Don't remove any contents during composition.
|
||||||
return false;
|
return false;
|
||||||
case CommandInsertTab:
|
case Command::InsertTab:
|
||||||
case CommandInsertBacktab:
|
case Command::InsertBacktab:
|
||||||
// Don't move focus during composition.
|
// Don't move focus during composition.
|
||||||
return false;
|
return false;
|
||||||
case CommandCharNext:
|
case Command::CharNext:
|
||||||
case CommandSelectCharNext:
|
case Command::SelectCharNext:
|
||||||
case CommandWordNext:
|
case Command::WordNext:
|
||||||
case CommandSelectWordNext:
|
case Command::SelectWordNext:
|
||||||
case CommandEndLine:
|
case Command::EndLine:
|
||||||
case CommandSelectEndLine:
|
case Command::SelectEndLine:
|
||||||
case CommandCharPrevious:
|
case Command::CharPrevious:
|
||||||
case CommandSelectCharPrevious:
|
case Command::SelectCharPrevious:
|
||||||
case CommandWordPrevious:
|
case Command::WordPrevious:
|
||||||
case CommandSelectWordPrevious:
|
case Command::SelectWordPrevious:
|
||||||
case CommandBeginLine:
|
case Command::BeginLine:
|
||||||
case CommandSelectBeginLine:
|
case Command::SelectBeginLine:
|
||||||
case CommandLinePrevious:
|
case Command::LinePrevious:
|
||||||
case CommandSelectLinePrevious:
|
case Command::SelectLinePrevious:
|
||||||
case CommandMoveTop:
|
case Command::MoveTop:
|
||||||
case CommandLineNext:
|
case Command::LineNext:
|
||||||
case CommandSelectLineNext:
|
case Command::SelectLineNext:
|
||||||
case CommandMoveBottom:
|
case Command::MoveBottom:
|
||||||
case CommandSelectBottom:
|
case Command::SelectBottom:
|
||||||
case CommandSelectPageUp:
|
case Command::SelectPageUp:
|
||||||
case CommandSelectPageDown:
|
case Command::SelectPageDown:
|
||||||
case CommandScrollBottom:
|
case Command::ScrollBottom:
|
||||||
case CommandScrollTop:
|
case Command::ScrollTop:
|
||||||
// Don't move selection during composition.
|
// Don't move selection during composition.
|
||||||
return false;
|
return false;
|
||||||
case CommandCancelOperation:
|
case Command::CancelOperation:
|
||||||
case CommandComplete:
|
case Command::Complete:
|
||||||
// Don't handle Escape key by ourselves during composition.
|
// Don't handle Escape key by ourselves during composition.
|
||||||
return false;
|
return false;
|
||||||
case CommandScrollPageUp:
|
case Command::ScrollPageUp:
|
||||||
case CommandScrollPageDown:
|
case Command::ScrollPageDown:
|
||||||
// Allow to scroll.
|
// Allow to scroll.
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -2621,8 +2621,8 @@ bool TextInputHandler::HandleCommand(Command aCommand) {
|
||||||
NS_WARNING_ASSERTION(keypressEvent.mNativeKeyEvent,
|
NS_WARNING_ASSERTION(keypressEvent.mNativeKeyEvent,
|
||||||
"Without native key event, NativeKeyBindings cannot compute aCommand");
|
"Without native key event, NativeKeyBindings cannot compute aCommand");
|
||||||
switch (aCommand) {
|
switch (aCommand) {
|
||||||
case CommandInsertLineBreak:
|
case Command::InsertLineBreak:
|
||||||
case CommandInsertParagraph: {
|
case Command::InsertParagraph: {
|
||||||
// Although, Shift+Enter and Enter are work differently in HTML
|
// Although, Shift+Enter and Enter are work differently in HTML
|
||||||
// editor, we should expose actual Shift state if it's caused by
|
// editor, we should expose actual Shift state if it's caused by
|
||||||
// Enter key for compatibility with Chromium. Chromium breaks
|
// Enter key for compatibility with Chromium. Chromium breaks
|
||||||
|
@ -2635,150 +2635,150 @@ bool TextInputHandler::HandleCommand(Command aCommand) {
|
||||||
keypressEvent.mKeyCode = NS_VK_RETURN;
|
keypressEvent.mKeyCode = NS_VK_RETURN;
|
||||||
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Enter;
|
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Enter;
|
||||||
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
||||||
if (aCommand == CommandInsertLineBreak) {
|
if (aCommand == Command::InsertLineBreak) {
|
||||||
// In default settings, Ctrl + Enter causes insertLineBreak command.
|
// In default settings, Ctrl + Enter causes insertLineBreak command.
|
||||||
// So, let's make Ctrl state active of the keypress event.
|
// So, let's make Ctrl state active of the keypress event.
|
||||||
keypressEvent.mModifiers |= MODIFIER_CONTROL;
|
keypressEvent.mModifiers |= MODIFIER_CONTROL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CommandInsertTab:
|
case Command::InsertTab:
|
||||||
case CommandInsertBacktab:
|
case Command::InsertBacktab:
|
||||||
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
||||||
keypressEvent.mKeyCode = NS_VK_TAB;
|
keypressEvent.mKeyCode = NS_VK_TAB;
|
||||||
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Tab;
|
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Tab;
|
||||||
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
||||||
if (aCommand == CommandInsertBacktab) {
|
if (aCommand == Command::InsertBacktab) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CommandDeleteCharBackward:
|
case Command::DeleteCharBackward:
|
||||||
case CommandDeleteToBeginningOfLine:
|
case Command::DeleteToBeginningOfLine:
|
||||||
case CommandDeleteWordBackward: {
|
case Command::DeleteWordBackward: {
|
||||||
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
||||||
keypressEvent.mKeyCode = NS_VK_BACK;
|
keypressEvent.mKeyCode = NS_VK_BACK;
|
||||||
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Backspace;
|
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Backspace;
|
||||||
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
||||||
if (aCommand == CommandDeleteToBeginningOfLine) {
|
if (aCommand == Command::DeleteToBeginningOfLine) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_META;
|
keypressEvent.mModifiers |= MODIFIER_META;
|
||||||
} else if (aCommand == CommandDeleteWordBackward) {
|
} else if (aCommand == Command::DeleteWordBackward) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_ALT;
|
keypressEvent.mModifiers |= MODIFIER_ALT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CommandDeleteCharForward:
|
case Command::DeleteCharForward:
|
||||||
case CommandDeleteWordForward: {
|
case Command::DeleteWordForward: {
|
||||||
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
||||||
keypressEvent.mKeyCode = NS_VK_DELETE;
|
keypressEvent.mKeyCode = NS_VK_DELETE;
|
||||||
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Delete;
|
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Delete;
|
||||||
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
||||||
if (aCommand == CommandDeleteWordForward) {
|
if (aCommand == Command::DeleteWordForward) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_ALT;
|
keypressEvent.mModifiers |= MODIFIER_ALT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CommandCharNext:
|
case Command::CharNext:
|
||||||
case CommandSelectCharNext:
|
case Command::SelectCharNext:
|
||||||
case CommandWordNext:
|
case Command::WordNext:
|
||||||
case CommandSelectWordNext:
|
case Command::SelectWordNext:
|
||||||
case CommandEndLine:
|
case Command::EndLine:
|
||||||
case CommandSelectEndLine: {
|
case Command::SelectEndLine: {
|
||||||
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
||||||
keypressEvent.mKeyCode = NS_VK_RIGHT;
|
keypressEvent.mKeyCode = NS_VK_RIGHT;
|
||||||
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_ArrowRight;
|
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_ArrowRight;
|
||||||
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
||||||
if (aCommand == CommandSelectCharNext || aCommand == CommandSelectWordNext ||
|
if (aCommand == Command::SelectCharNext || aCommand == Command::SelectWordNext ||
|
||||||
aCommand == CommandSelectEndLine) {
|
aCommand == Command::SelectEndLine) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
||||||
}
|
}
|
||||||
if (aCommand == CommandWordNext || aCommand == CommandSelectWordNext) {
|
if (aCommand == Command::WordNext || aCommand == Command::SelectWordNext) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_ALT;
|
keypressEvent.mModifiers |= MODIFIER_ALT;
|
||||||
}
|
}
|
||||||
if (aCommand == CommandEndLine || aCommand == CommandSelectEndLine) {
|
if (aCommand == Command::EndLine || aCommand == Command::SelectEndLine) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_META;
|
keypressEvent.mModifiers |= MODIFIER_META;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CommandCharPrevious:
|
case Command::CharPrevious:
|
||||||
case CommandSelectCharPrevious:
|
case Command::SelectCharPrevious:
|
||||||
case CommandWordPrevious:
|
case Command::WordPrevious:
|
||||||
case CommandSelectWordPrevious:
|
case Command::SelectWordPrevious:
|
||||||
case CommandBeginLine:
|
case Command::BeginLine:
|
||||||
case CommandSelectBeginLine: {
|
case Command::SelectBeginLine: {
|
||||||
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
||||||
keypressEvent.mKeyCode = NS_VK_LEFT;
|
keypressEvent.mKeyCode = NS_VK_LEFT;
|
||||||
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_ArrowLeft;
|
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_ArrowLeft;
|
||||||
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
||||||
if (aCommand == CommandSelectCharPrevious || aCommand == CommandSelectWordPrevious ||
|
if (aCommand == Command::SelectCharPrevious || aCommand == Command::SelectWordPrevious ||
|
||||||
aCommand == CommandSelectBeginLine) {
|
aCommand == Command::SelectBeginLine) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
||||||
}
|
}
|
||||||
if (aCommand == CommandWordPrevious || aCommand == CommandSelectWordPrevious) {
|
if (aCommand == Command::WordPrevious || aCommand == Command::SelectWordPrevious) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_ALT;
|
keypressEvent.mModifiers |= MODIFIER_ALT;
|
||||||
}
|
}
|
||||||
if (aCommand == CommandBeginLine || aCommand == CommandSelectBeginLine) {
|
if (aCommand == Command::BeginLine || aCommand == Command::SelectBeginLine) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_META;
|
keypressEvent.mModifiers |= MODIFIER_META;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CommandLinePrevious:
|
case Command::LinePrevious:
|
||||||
case CommandSelectLinePrevious:
|
case Command::SelectLinePrevious:
|
||||||
case CommandMoveTop:
|
case Command::MoveTop:
|
||||||
case CommandSelectTop: {
|
case Command::SelectTop: {
|
||||||
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
||||||
keypressEvent.mKeyCode = NS_VK_UP;
|
keypressEvent.mKeyCode = NS_VK_UP;
|
||||||
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_ArrowUp;
|
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_ArrowUp;
|
||||||
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
||||||
if (aCommand == CommandSelectLinePrevious || aCommand == CommandSelectTop) {
|
if (aCommand == Command::SelectLinePrevious || aCommand == Command::SelectTop) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
||||||
}
|
}
|
||||||
if (aCommand == CommandMoveTop || aCommand == CommandSelectTop) {
|
if (aCommand == Command::MoveTop || aCommand == Command::SelectTop) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_META;
|
keypressEvent.mModifiers |= MODIFIER_META;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CommandLineNext:
|
case Command::LineNext:
|
||||||
case CommandSelectLineNext:
|
case Command::SelectLineNext:
|
||||||
case CommandMoveBottom:
|
case Command::MoveBottom:
|
||||||
case CommandSelectBottom: {
|
case Command::SelectBottom: {
|
||||||
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
||||||
keypressEvent.mKeyCode = NS_VK_DOWN;
|
keypressEvent.mKeyCode = NS_VK_DOWN;
|
||||||
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_ArrowDown;
|
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_ArrowDown;
|
||||||
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
||||||
if (aCommand == CommandSelectLineNext || aCommand == CommandSelectBottom) {
|
if (aCommand == Command::SelectLineNext || aCommand == Command::SelectBottom) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
||||||
}
|
}
|
||||||
if (aCommand == CommandMoveBottom || aCommand == CommandSelectBottom) {
|
if (aCommand == Command::MoveBottom || aCommand == Command::SelectBottom) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_META;
|
keypressEvent.mModifiers |= MODIFIER_META;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CommandScrollPageUp:
|
case Command::ScrollPageUp:
|
||||||
case CommandSelectPageUp: {
|
case Command::SelectPageUp: {
|
||||||
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
||||||
keypressEvent.mKeyCode = NS_VK_PAGE_UP;
|
keypressEvent.mKeyCode = NS_VK_PAGE_UP;
|
||||||
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_PageUp;
|
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_PageUp;
|
||||||
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
||||||
if (aCommand == CommandSelectPageUp) {
|
if (aCommand == Command::SelectPageUp) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CommandScrollPageDown:
|
case Command::ScrollPageDown:
|
||||||
case CommandSelectPageDown: {
|
case Command::SelectPageDown: {
|
||||||
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
||||||
keypressEvent.mKeyCode = NS_VK_PAGE_DOWN;
|
keypressEvent.mKeyCode = NS_VK_PAGE_DOWN;
|
||||||
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_PageDown;
|
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_PageDown;
|
||||||
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
||||||
if (aCommand == CommandSelectPageDown) {
|
if (aCommand == Command::SelectPageDown) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
keypressEvent.mModifiers |= MODIFIER_SHIFT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CommandScrollBottom:
|
case Command::ScrollBottom:
|
||||||
case CommandScrollTop: {
|
case Command::ScrollTop: {
|
||||||
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
||||||
if (aCommand == CommandScrollBottom) {
|
if (aCommand == Command::ScrollBottom) {
|
||||||
keypressEvent.mKeyCode = NS_VK_END;
|
keypressEvent.mKeyCode = NS_VK_END;
|
||||||
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_End;
|
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_End;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2788,13 +2788,13 @@ bool TextInputHandler::HandleCommand(Command aCommand) {
|
||||||
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CommandCancelOperation:
|
case Command::CancelOperation:
|
||||||
case CommandComplete: {
|
case Command::Complete: {
|
||||||
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
nsCocoaUtils::InitInputEvent(keypressEvent, keyEvent);
|
||||||
keypressEvent.mKeyCode = NS_VK_ESCAPE;
|
keypressEvent.mKeyCode = NS_VK_ESCAPE;
|
||||||
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Escape;
|
keypressEvent.mKeyNameIndex = KEY_NAME_INDEX_Escape;
|
||||||
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
keypressEvent.mModifiers &= ~(MODIFIER_CONTROL | MODIFIER_ALT | MODIFIER_META);
|
||||||
if (aCommand == CommandComplete) {
|
if (aCommand == Command::Complete) {
|
||||||
keypressEvent.mModifiers |= MODIFIER_ALT;
|
keypressEvent.mModifiers |= MODIFIER_ALT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2852,7 +2852,7 @@ bool TextInputHandler::HandleCommand(Command aCommand) {
|
||||||
|
|
||||||
// If keypress event isn't dispatched as expected, we should fallback to
|
// If keypress event isn't dispatched as expected, we should fallback to
|
||||||
// using composition events.
|
// using composition events.
|
||||||
if (aCommand == CommandInsertLineBreak || aCommand == CommandInsertParagraph) {
|
if (aCommand == Command::InsertLineBreak || aCommand == Command::InsertParagraph) {
|
||||||
NSAttributedString* lineBreaker = [[NSAttributedString alloc] initWithString:@"\n"];
|
NSAttributedString* lineBreaker = [[NSAttributedString alloc] initWithString:@"\n"];
|
||||||
InsertTextAsCommittingComposition(lineBreaker, nullptr);
|
InsertTextAsCommittingComposition(lineBreaker, nullptr);
|
||||||
if (currentKeyEvent) {
|
if (currentKeyEvent) {
|
||||||
|
@ -2953,8 +2953,8 @@ bool TextInputHandler::DoCommandBySelector(const char* aSelector) {
|
||||||
// ChildView only when current key event is proper event to fire Escape
|
// ChildView only when current key event is proper event to fire Escape
|
||||||
// keypress event.
|
// keypress event.
|
||||||
if (!strcmp(aSelector, "cancelOperatiorn:") && currentKeyEvent &&
|
if (!strcmp(aSelector, "cancelOperatiorn:") && currentKeyEvent &&
|
||||||
currentKeyEvent->IsProperKeyEvent(CommandCancelOperation)) {
|
currentKeyEvent->IsProperKeyEvent(Command::CancelOperation)) {
|
||||||
return HandleCommand(CommandCancelOperation);
|
return HandleCommand(Command::CancelOperation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, we've not handled the command yet. Propagate the command
|
// Otherwise, we've not handled the command yet. Propagate the command
|
||||||
|
|
|
@ -4908,252 +4908,252 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) {
|
||||||
|
|
||||||
- (void)insertNewline:(id)sender {
|
- (void)insertNewline:(id)sender {
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandInsertParagraph);
|
mTextInputHandler->HandleCommand(Command::InsertParagraph);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)insertLineBreak:(id)sender {
|
- (void)insertLineBreak:(id)sender {
|
||||||
// Ctrl + Enter in the default settings.
|
// Ctrl + Enter in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandInsertLineBreak);
|
mTextInputHandler->HandleCommand(Command::InsertLineBreak);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)deleteBackward:(id)sender {
|
- (void)deleteBackward:(id)sender {
|
||||||
// Backspace in the default settings.
|
// Backspace in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandDeleteCharBackward);
|
mTextInputHandler->HandleCommand(Command::DeleteCharBackward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)deleteBackwardByDecomposingPreviousCharacter:(id)sender {
|
- (void)deleteBackwardByDecomposingPreviousCharacter:(id)sender {
|
||||||
// Ctrl + Backspace in the default settings.
|
// Ctrl + Backspace in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandDeleteCharBackward);
|
mTextInputHandler->HandleCommand(Command::DeleteCharBackward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)deleteWordBackward:(id)sender {
|
- (void)deleteWordBackward:(id)sender {
|
||||||
// Alt + Backspace in the default settings.
|
// Alt + Backspace in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandDeleteWordBackward);
|
mTextInputHandler->HandleCommand(Command::DeleteWordBackward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)deleteToBeginningOfBackward:(id)sender {
|
- (void)deleteToBeginningOfBackward:(id)sender {
|
||||||
// Command + Backspace in the default settings.
|
// Command + Backspace in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandDeleteToBeginningOfLine);
|
mTextInputHandler->HandleCommand(Command::DeleteToBeginningOfLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)deleteForward:(id)sender {
|
- (void)deleteForward:(id)sender {
|
||||||
// Delete in the default settings.
|
// Delete in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandDeleteCharForward);
|
mTextInputHandler->HandleCommand(Command::DeleteCharForward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)deleteWordForward:(id)sender {
|
- (void)deleteWordForward:(id)sender {
|
||||||
// Alt + Delete in the default settings.
|
// Alt + Delete in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandDeleteWordForward);
|
mTextInputHandler->HandleCommand(Command::DeleteWordForward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)insertTab:(id)sender {
|
- (void)insertTab:(id)sender {
|
||||||
// Tab in the default settings.
|
// Tab in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandInsertTab);
|
mTextInputHandler->HandleCommand(Command::InsertTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)insertBacktab:(id)sender {
|
- (void)insertBacktab:(id)sender {
|
||||||
// Shift + Tab in the default settings.
|
// Shift + Tab in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandInsertBacktab);
|
mTextInputHandler->HandleCommand(Command::InsertBacktab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveRight:(id)sender {
|
- (void)moveRight:(id)sender {
|
||||||
// RightArrow in the default settings.
|
// RightArrow in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandCharNext);
|
mTextInputHandler->HandleCommand(Command::CharNext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveRightAndModifySelection:(id)sender {
|
- (void)moveRightAndModifySelection:(id)sender {
|
||||||
// Shift + RightArrow in the default settings.
|
// Shift + RightArrow in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandSelectCharNext);
|
mTextInputHandler->HandleCommand(Command::SelectCharNext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveWordRight:(id)sender {
|
- (void)moveWordRight:(id)sender {
|
||||||
// Alt + RightArrow in the default settings.
|
// Alt + RightArrow in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandWordNext);
|
mTextInputHandler->HandleCommand(Command::WordNext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveWordRightAndModifySelection:(id)sender {
|
- (void)moveWordRightAndModifySelection:(id)sender {
|
||||||
// Alt + Shift + RightArrow in the default settings.
|
// Alt + Shift + RightArrow in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandSelectWordNext);
|
mTextInputHandler->HandleCommand(Command::SelectWordNext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveToRightEndOfLine:(id)sender {
|
- (void)moveToRightEndOfLine:(id)sender {
|
||||||
// Command + RightArrow in the default settings.
|
// Command + RightArrow in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandEndLine);
|
mTextInputHandler->HandleCommand(Command::EndLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveToRightEndOfLineAndModifySelection:(id)sender {
|
- (void)moveToRightEndOfLineAndModifySelection:(id)sender {
|
||||||
// Command + Shift + RightArrow in the default settings.
|
// Command + Shift + RightArrow in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandSelectEndLine);
|
mTextInputHandler->HandleCommand(Command::SelectEndLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveLeft:(id)sender {
|
- (void)moveLeft:(id)sender {
|
||||||
// LeftArrow in the default settings.
|
// LeftArrow in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandCharPrevious);
|
mTextInputHandler->HandleCommand(Command::CharPrevious);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveLeftAndModifySelection:(id)sender {
|
- (void)moveLeftAndModifySelection:(id)sender {
|
||||||
// Shift + LeftArrow in the default settings.
|
// Shift + LeftArrow in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandSelectCharPrevious);
|
mTextInputHandler->HandleCommand(Command::SelectCharPrevious);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveWordLeft:(id)sender {
|
- (void)moveWordLeft:(id)sender {
|
||||||
// Alt + LeftArrow in the default settings.
|
// Alt + LeftArrow in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandWordPrevious);
|
mTextInputHandler->HandleCommand(Command::WordPrevious);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveWordLeftAndModifySelection:(id)sender {
|
- (void)moveWordLeftAndModifySelection:(id)sender {
|
||||||
// Alt + Shift + LeftArrow in the default settings.
|
// Alt + Shift + LeftArrow in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandSelectWordPrevious);
|
mTextInputHandler->HandleCommand(Command::SelectWordPrevious);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveToLeftEndOfLine:(id)sender {
|
- (void)moveToLeftEndOfLine:(id)sender {
|
||||||
// Command + LeftArrow in the default settings.
|
// Command + LeftArrow in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandBeginLine);
|
mTextInputHandler->HandleCommand(Command::BeginLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveToLeftEndOfLineAndModifySelection:(id)sender {
|
- (void)moveToLeftEndOfLineAndModifySelection:(id)sender {
|
||||||
// Command + Shift + LeftArrow in the default settings.
|
// Command + Shift + LeftArrow in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandSelectBeginLine);
|
mTextInputHandler->HandleCommand(Command::SelectBeginLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveUp:(id)sender {
|
- (void)moveUp:(id)sender {
|
||||||
// ArrowUp in the default settings.
|
// ArrowUp in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandLinePrevious);
|
mTextInputHandler->HandleCommand(Command::LinePrevious);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveUpAndModifySelection:(id)sender {
|
- (void)moveUpAndModifySelection:(id)sender {
|
||||||
// Shift + ArrowUp in the default settings.
|
// Shift + ArrowUp in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandSelectLinePrevious);
|
mTextInputHandler->HandleCommand(Command::SelectLinePrevious);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveToBeginningOfDocument:(id)sender {
|
- (void)moveToBeginningOfDocument:(id)sender {
|
||||||
// Command + ArrowUp in the default settings.
|
// Command + ArrowUp in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandMoveTop);
|
mTextInputHandler->HandleCommand(Command::MoveTop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveToBeginningOfDocumentAndModifySelection:(id)sender {
|
- (void)moveToBeginningOfDocumentAndModifySelection:(id)sender {
|
||||||
// Command + Shift + ArrowUp or Shift + Home in the default settings.
|
// Command + Shift + ArrowUp or Shift + Home in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandSelectTop);
|
mTextInputHandler->HandleCommand(Command::SelectTop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveDown:(id)sender {
|
- (void)moveDown:(id)sender {
|
||||||
// ArrowDown in the default settings.
|
// ArrowDown in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandLineNext);
|
mTextInputHandler->HandleCommand(Command::LineNext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveDownAndModifySelection:(id)sender {
|
- (void)moveDownAndModifySelection:(id)sender {
|
||||||
// Shift + ArrowDown in the default settings.
|
// Shift + ArrowDown in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandSelectLineNext);
|
mTextInputHandler->HandleCommand(Command::SelectLineNext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveToEndOfDocument:(id)sender {
|
- (void)moveToEndOfDocument:(id)sender {
|
||||||
// Command + ArrowDown in the default settings.
|
// Command + ArrowDown in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandMoveBottom);
|
mTextInputHandler->HandleCommand(Command::MoveBottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveToEndOfDocumentAndModifySelection:(id)sender {
|
- (void)moveToEndOfDocumentAndModifySelection:(id)sender {
|
||||||
// Command + Shift + ArrowDown or Shift + End in the default settings.
|
// Command + Shift + ArrowDown or Shift + End in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandSelectBottom);
|
mTextInputHandler->HandleCommand(Command::SelectBottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scrollPageUp:(id)sender {
|
- (void)scrollPageUp:(id)sender {
|
||||||
// PageUp in the default settings.
|
// PageUp in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandScrollPageUp);
|
mTextInputHandler->HandleCommand(Command::ScrollPageUp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)pageUpAndModifySelection:(id)sender {
|
- (void)pageUpAndModifySelection:(id)sender {
|
||||||
// Shift + PageUp in the default settings.
|
// Shift + PageUp in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandSelectPageUp);
|
mTextInputHandler->HandleCommand(Command::SelectPageUp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scrollPageDown:(id)sender {
|
- (void)scrollPageDown:(id)sender {
|
||||||
// PageDown in the default settings.
|
// PageDown in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandScrollPageDown);
|
mTextInputHandler->HandleCommand(Command::ScrollPageDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)pageDownAndModifySelection:(id)sender {
|
- (void)pageDownAndModifySelection:(id)sender {
|
||||||
// Shift + PageDown in the default settings.
|
// Shift + PageDown in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandSelectPageDown);
|
mTextInputHandler->HandleCommand(Command::SelectPageDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scrollToEndOfDocument:(id)sender {
|
- (void)scrollToEndOfDocument:(id)sender {
|
||||||
// End in the default settings.
|
// End in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandScrollBottom);
|
mTextInputHandler->HandleCommand(Command::ScrollBottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scrollToBeginningOfDocument:(id)sender {
|
- (void)scrollToBeginningOfDocument:(id)sender {
|
||||||
// Home in the default settings.
|
// Home in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandScrollTop);
|
mTextInputHandler->HandleCommand(Command::ScrollTop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5164,7 +5164,7 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) {
|
||||||
- (void)complete:(id)sender {
|
- (void)complete:(id)sender {
|
||||||
// Alt + Escape or Alt + Shift + Escape in the default settings.
|
// Alt + Escape or Alt + Shift + Escape in the default settings.
|
||||||
if (mTextInputHandler) {
|
if (mTextInputHandler) {
|
||||||
mTextInputHandler->HandleCommand(CommandComplete);
|
mTextInputHandler->HandleCommand(Command::Complete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,15 +22,20 @@ namespace widget {
|
||||||
static nsTArray<CommandInt>* gCurrentCommands = nullptr;
|
static nsTArray<CommandInt>* gCurrentCommands = nullptr;
|
||||||
static bool gHandled = false;
|
static bool gHandled = false;
|
||||||
|
|
||||||
|
inline void AddCommand(Command aCommand) {
|
||||||
|
MOZ_ASSERT(gCurrentCommands);
|
||||||
|
gCurrentCommands->AppendElement(static_cast<CommandInt>(aCommand));
|
||||||
|
}
|
||||||
|
|
||||||
// Common GtkEntry and GtkTextView signals
|
// Common GtkEntry and GtkTextView signals
|
||||||
static void copy_clipboard_cb(GtkWidget* w, gpointer user_data) {
|
static void copy_clipboard_cb(GtkWidget* w, gpointer user_data) {
|
||||||
gCurrentCommands->AppendElement(CommandCopy);
|
AddCommand(Command::Copy);
|
||||||
g_signal_stop_emission_by_name(w, "copy_clipboard");
|
g_signal_stop_emission_by_name(w, "copy_clipboard");
|
||||||
gHandled = true;
|
gHandled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cut_clipboard_cb(GtkWidget* w, gpointer user_data) {
|
static void cut_clipboard_cb(GtkWidget* w, gpointer user_data) {
|
||||||
gCurrentCommands->AppendElement(CommandCut);
|
AddCommand(Command::Cut);
|
||||||
g_signal_stop_emission_by_name(w, "cut_clipboard");
|
g_signal_stop_emission_by_name(w, "cut_clipboard");
|
||||||
gHandled = true;
|
gHandled = true;
|
||||||
}
|
}
|
||||||
|
@ -42,18 +47,24 @@ static void cut_clipboard_cb(GtkWidget* w, gpointer user_data) {
|
||||||
|
|
||||||
static const Command sDeleteCommands[][2] = {
|
static const Command sDeleteCommands[][2] = {
|
||||||
// backward, forward
|
// backward, forward
|
||||||
{CommandDeleteCharBackward, CommandDeleteCharForward}, // CHARS
|
// CHARS
|
||||||
{CommandDeleteWordBackward, CommandDeleteWordForward}, // WORD_ENDS
|
{Command::DeleteCharBackward, Command::DeleteCharForward},
|
||||||
{CommandDeleteWordBackward, CommandDeleteWordForward}, // WORDS
|
// WORD_ENDS
|
||||||
{CommandDeleteToBeginningOfLine, CommandDeleteToEndOfLine}, // LINES
|
{Command::DeleteWordBackward, Command::DeleteWordForward},
|
||||||
{CommandDeleteToBeginningOfLine, CommandDeleteToEndOfLine}, // LINE_ENDS
|
// WORDS
|
||||||
{CommandDeleteToBeginningOfLine,
|
{Command::DeleteWordBackward, Command::DeleteWordForward},
|
||||||
CommandDeleteToEndOfLine}, // PARAGRAPH_ENDS
|
// LINES
|
||||||
{CommandDeleteToBeginningOfLine, CommandDeleteToEndOfLine}, // PARAGRAPHS
|
{Command::DeleteToBeginningOfLine, Command::DeleteToEndOfLine},
|
||||||
|
// LINE_ENDS
|
||||||
|
{Command::DeleteToBeginningOfLine, Command::DeleteToEndOfLine},
|
||||||
|
// PARAGRAPH_ENDS
|
||||||
|
{Command::DeleteToBeginningOfLine, Command::DeleteToEndOfLine},
|
||||||
|
// PARAGRAPHS
|
||||||
|
{Command::DeleteToBeginningOfLine, Command::DeleteToEndOfLine},
|
||||||
// This deletes from the end of the previous word to the beginning of the
|
// This deletes from the end of the previous word to the beginning of the
|
||||||
// next word, but only if the caret is not in a word.
|
// next word, but only if the caret is not in a word.
|
||||||
// XXX need to implement in editor
|
// XXX need to implement in editor
|
||||||
{CommandDoNothing, CommandDoNothing} // WHITESPACE
|
{Command::DoNothing, Command::DoNothing} // WHITESPACE
|
||||||
};
|
};
|
||||||
|
|
||||||
static void delete_from_cursor_cb(GtkWidget* w, GtkDeleteType del_type,
|
static void delete_from_cursor_cb(GtkWidget* w, GtkDeleteType del_type,
|
||||||
|
@ -91,31 +102,31 @@ static void delete_from_cursor_cb(GtkWidget* w, GtkDeleteType del_type,
|
||||||
// This works like word_ends, except we first move the caret to the
|
// This works like word_ends, except we first move the caret to the
|
||||||
// beginning/end of the current word.
|
// beginning/end of the current word.
|
||||||
if (forward) {
|
if (forward) {
|
||||||
gCurrentCommands->AppendElement(CommandWordNext);
|
AddCommand(Command::WordNext);
|
||||||
gCurrentCommands->AppendElement(CommandWordPrevious);
|
AddCommand(Command::WordPrevious);
|
||||||
} else {
|
} else {
|
||||||
gCurrentCommands->AppendElement(CommandWordPrevious);
|
AddCommand(Command::WordPrevious);
|
||||||
gCurrentCommands->AppendElement(CommandWordNext);
|
AddCommand(Command::WordNext);
|
||||||
}
|
}
|
||||||
} else if (del_type == GTK_DELETE_DISPLAY_LINES ||
|
} else if (del_type == GTK_DELETE_DISPLAY_LINES ||
|
||||||
del_type == GTK_DELETE_PARAGRAPHS) {
|
del_type == GTK_DELETE_PARAGRAPHS) {
|
||||||
// This works like display_line_ends, except we first move the caret to the
|
// This works like display_line_ends, except we first move the caret to the
|
||||||
// beginning/end of the current line.
|
// beginning/end of the current line.
|
||||||
if (forward) {
|
if (forward) {
|
||||||
gCurrentCommands->AppendElement(CommandBeginLine);
|
AddCommand(Command::BeginLine);
|
||||||
} else {
|
} else {
|
||||||
gCurrentCommands->AppendElement(CommandEndLine);
|
AddCommand(Command::EndLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command command = sDeleteCommands[del_type][forward];
|
Command command = sDeleteCommands[del_type][forward];
|
||||||
if (!command) {
|
if (command == Command::DoNothing) {
|
||||||
return; // unsupported command
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int absCount = Abs(count);
|
unsigned int absCount = Abs(count);
|
||||||
for (unsigned int i = 0; i < absCount; ++i) {
|
for (unsigned int i = 0; i < absCount; ++i) {
|
||||||
gCurrentCommands->AppendElement(command);
|
AddCommand(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,35 +136,35 @@ static const Command sMoveCommands[][2][2] = {
|
||||||
// and visual position, which is always left/right.
|
// and visual position, which is always left/right.
|
||||||
// We should fix this to work the same way for RTL text input.
|
// We should fix this to work the same way for RTL text input.
|
||||||
{// LOGICAL_POSITIONS
|
{// LOGICAL_POSITIONS
|
||||||
{CommandCharPrevious, CommandCharNext},
|
{Command::CharPrevious, Command::CharNext},
|
||||||
{CommandSelectCharPrevious, CommandSelectCharNext}},
|
{Command::SelectCharPrevious, Command::SelectCharNext}},
|
||||||
{// VISUAL_POSITIONS
|
{// VISUAL_POSITIONS
|
||||||
{CommandCharPrevious, CommandCharNext},
|
{Command::CharPrevious, Command::CharNext},
|
||||||
{CommandSelectCharPrevious, CommandSelectCharNext}},
|
{Command::SelectCharPrevious, Command::SelectCharNext}},
|
||||||
{// WORDS
|
{// WORDS
|
||||||
{CommandWordPrevious, CommandWordNext},
|
{Command::WordPrevious, Command::WordNext},
|
||||||
{CommandSelectWordPrevious, CommandSelectWordNext}},
|
{Command::SelectWordPrevious, Command::SelectWordNext}},
|
||||||
{// DISPLAY_LINES
|
{// DISPLAY_LINES
|
||||||
{CommandLinePrevious, CommandLineNext},
|
{Command::LinePrevious, Command::LineNext},
|
||||||
{CommandSelectLinePrevious, CommandSelectLineNext}},
|
{Command::SelectLinePrevious, Command::SelectLineNext}},
|
||||||
{// DISPLAY_LINE_ENDS
|
{// DISPLAY_LINE_ENDS
|
||||||
{CommandBeginLine, CommandEndLine},
|
{Command::BeginLine, Command::EndLine},
|
||||||
{CommandSelectBeginLine, CommandSelectEndLine}},
|
{Command::SelectBeginLine, Command::SelectEndLine}},
|
||||||
{// PARAGRAPHS
|
{// PARAGRAPHS
|
||||||
{CommandLinePrevious, CommandLineNext},
|
{Command::LinePrevious, Command::LineNext},
|
||||||
{CommandSelectLinePrevious, CommandSelectLineNext}},
|
{Command::SelectLinePrevious, Command::SelectLineNext}},
|
||||||
{// PARAGRAPH_ENDS
|
{// PARAGRAPH_ENDS
|
||||||
{CommandBeginLine, CommandEndLine},
|
{Command::BeginLine, Command::EndLine},
|
||||||
{CommandSelectBeginLine, CommandSelectEndLine}},
|
{Command::SelectBeginLine, Command::SelectEndLine}},
|
||||||
{// PAGES
|
{// PAGES
|
||||||
{CommandMovePageUp, CommandMovePageDown},
|
{Command::MovePageUp, Command::MovePageDown},
|
||||||
{CommandSelectPageUp, CommandSelectPageDown}},
|
{Command::SelectPageUp, Command::SelectPageDown}},
|
||||||
{// BUFFER_ENDS
|
{// BUFFER_ENDS
|
||||||
{CommandMoveTop, CommandMoveBottom},
|
{Command::MoveTop, Command::MoveBottom},
|
||||||
{CommandSelectTop, CommandSelectBottom}},
|
{Command::SelectTop, Command::SelectBottom}},
|
||||||
{// HORIZONTAL_PAGES (unsupported)
|
{// HORIZONTAL_PAGES (unsupported)
|
||||||
{CommandDoNothing, CommandDoNothing},
|
{Command::DoNothing, Command::DoNothing},
|
||||||
{CommandDoNothing, CommandDoNothing}}};
|
{Command::DoNothing, Command::DoNothing}}};
|
||||||
|
|
||||||
static void move_cursor_cb(GtkWidget* w, GtkMovementStep step, gint count,
|
static void move_cursor_cb(GtkWidget* w, GtkMovementStep step, gint count,
|
||||||
gboolean extend_selection, gpointer user_data) {
|
gboolean extend_selection, gpointer user_data) {
|
||||||
|
@ -171,25 +182,25 @@ static void move_cursor_cb(GtkWidget* w, GtkMovementStep step, gint count,
|
||||||
}
|
}
|
||||||
|
|
||||||
Command command = sMoveCommands[step][extend_selection][forward];
|
Command command = sMoveCommands[step][extend_selection][forward];
|
||||||
if (!command) {
|
if (command == Command::DoNothing) {
|
||||||
return; // unsupported command
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int absCount = Abs(count);
|
unsigned int absCount = Abs(count);
|
||||||
for (unsigned int i = 0; i < absCount; ++i) {
|
for (unsigned int i = 0; i < absCount; ++i) {
|
||||||
gCurrentCommands->AppendElement(command);
|
AddCommand(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void paste_clipboard_cb(GtkWidget* w, gpointer user_data) {
|
static void paste_clipboard_cb(GtkWidget* w, gpointer user_data) {
|
||||||
gCurrentCommands->AppendElement(CommandPaste);
|
AddCommand(Command::Paste);
|
||||||
g_signal_stop_emission_by_name(w, "paste_clipboard");
|
g_signal_stop_emission_by_name(w, "paste_clipboard");
|
||||||
gHandled = true;
|
gHandled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GtkTextView-only signals
|
// GtkTextView-only signals
|
||||||
static void select_all_cb(GtkWidget* w, gboolean select, gpointer user_data) {
|
static void select_all_cb(GtkWidget* w, gboolean select, gpointer user_data) {
|
||||||
gCurrentCommands->AppendElement(CommandSelectAll);
|
AddCommand(Command::SelectAll);
|
||||||
g_signal_stop_emission_by_name(w, "select_all");
|
g_signal_stop_emission_by_name(w, "select_all");
|
||||||
gHandled = true;
|
gHandled = true;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче