Revert "BTextView: Update word-wise/line-wise shortcuts"
This reverts commit 74ef92bc55.
Change-Id: I441d9cce87670e17141051fded594ae8aa6fc1fd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9299
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
@@ -470,23 +470,19 @@ private:
|
||||
LayoutData* fLayoutData;
|
||||
int32 fLastClickOffset;
|
||||
|
||||
bool fInstalledNavigateCommandWordwiseShortcuts : 1;
|
||||
bool fInstalledNavigateOptionWordwiseShortcuts : 1;
|
||||
bool fInstalledSelectOptionWordwiseShortcuts : 1;
|
||||
bool fInstalledRemoveCommandLinewiseShortcuts : 1;
|
||||
bool fInstalledRemoveOptionWordwiseShortcuts : 1;
|
||||
|
||||
bool fInstalledNavigateCommandHorizontalLinewiseShortcuts : 1;
|
||||
bool fInstalledNavigateCommandVerticalLinewiseShortcuts : 1;
|
||||
bool fInstalledNavigateControlHorizontalLinewiseShortcuts : 1;
|
||||
bool fInstalledNavigateControlVerticalLinewiseShortcuts : 1;
|
||||
bool fInstalledSelectCommandHorizontalLinewiseShortcuts : 1;
|
||||
bool fInstalledSelectCommandVerticalLinewiseShortcuts : 1;
|
||||
bool fInstalledSelectControlHorizontalLinewiseShortcuts : 1;
|
||||
bool fInstalledSelectControlVerticalLinewiseShortcuts : 1;
|
||||
|
||||
bool fInstalledNavigateOptionLinewiseShortcuts : 1;
|
||||
bool fInstalledNavigateHomeEndDocwiseShortcuts : 1;
|
||||
|
||||
bool fInstalledSelectCommandWordwiseShortcuts : 1;
|
||||
bool fInstalledSelectOptionWordwiseShortcuts : 1;
|
||||
bool fInstalledSelectOptionLinewiseShortcuts : 1;
|
||||
bool fInstalledSelectHomeEndDocwiseShortcuts : 1;
|
||||
|
||||
bool fInstalledRemoveCommandWordwiseShortcuts : 1;
|
||||
bool fInstalledRemoveOptionWordwiseShortcuts : 1;
|
||||
|
||||
uint32 _reserved[6];
|
||||
};
|
||||
|
||||
|
||||
+202
-317
@@ -3230,23 +3230,19 @@ BTextView::_InitObject(BRect textRect, const BFont* initialFont,
|
||||
fLines = new LineBuffer;
|
||||
fStyles = new StyleBuffer(&font, initialColor);
|
||||
|
||||
fInstalledNavigateCommandWordwiseShortcuts = false;
|
||||
fInstalledNavigateOptionWordwiseShortcuts = false;
|
||||
fInstalledSelectOptionWordwiseShortcuts = false;
|
||||
fInstalledRemoveCommandLinewiseShortcuts = false;
|
||||
fInstalledRemoveOptionWordwiseShortcuts = false;
|
||||
|
||||
fInstalledNavigateCommandHorizontalLinewiseShortcuts = false;
|
||||
fInstalledNavigateCommandVerticalLinewiseShortcuts = false;
|
||||
fInstalledNavigateControlHorizontalLinewiseShortcuts = false;
|
||||
fInstalledNavigateControlVerticalLinewiseShortcuts = false;
|
||||
fInstalledSelectCommandHorizontalLinewiseShortcuts = false;
|
||||
fInstalledSelectCommandVerticalLinewiseShortcuts = false;
|
||||
fInstalledSelectControlHorizontalLinewiseShortcuts = false;
|
||||
fInstalledSelectControlVerticalLinewiseShortcuts = false;
|
||||
|
||||
fInstalledNavigateOptionLinewiseShortcuts = false;
|
||||
fInstalledNavigateHomeEndDocwiseShortcuts = false;
|
||||
|
||||
fInstalledSelectCommandWordwiseShortcuts = false;
|
||||
fInstalledSelectOptionWordwiseShortcuts = false;
|
||||
fInstalledSelectOptionLinewiseShortcuts = false;
|
||||
fInstalledSelectHomeEndDocwiseShortcuts = false;
|
||||
|
||||
fInstalledRemoveCommandWordwiseShortcuts = false;
|
||||
fInstalledRemoveOptionWordwiseShortcuts = false;
|
||||
|
||||
// We put these here instead of in the constructor initializer list
|
||||
// to have less code duplication, and a single place where to do changes
|
||||
// if needed.
|
||||
@@ -3312,14 +3308,9 @@ BTextView::_HandleBackspace(int32 modifiers)
|
||||
bool optionKeyDown = (modifiers & B_OPTION_KEY) != 0;
|
||||
bool commandKeyDown = (modifiers & B_COMMAND_KEY) != 0;
|
||||
|
||||
if (optionKeyDown) {
|
||||
// delete previous word with option held down
|
||||
if ((commandKeyDown || optionKeyDown) && !controlKeyDown) {
|
||||
fSelStart = _PreviousWordStart(fCaretOffset - 1);
|
||||
fSelEnd = fCaretOffset;
|
||||
} else if (commandKeyDown && !controlKeyDown) {
|
||||
// delete to beginning of line with command held down
|
||||
fSelStart = _PreviousLineStart(fCaretOffset);
|
||||
fSelEnd = fCaretOffset;
|
||||
}
|
||||
|
||||
if (fUndo) {
|
||||
@@ -3385,10 +3376,8 @@ BTextView::_HandleArrowKey(uint32 arrowKey, int32 modifiers)
|
||||
else if (fSelStart != fSelEnd && !shiftKeyDown)
|
||||
fCaretOffset = fSelStart;
|
||||
else {
|
||||
if (optionKeyDown)
|
||||
if ((commandKeyDown || optionKeyDown) && !controlKeyDown)
|
||||
fCaretOffset = _PreviousWordStart(fCaretOffset - 1);
|
||||
else if (commandKeyDown || controlKeyDown)
|
||||
fCaretOffset = _PreviousLineStart(fCaretOffset);
|
||||
else
|
||||
fCaretOffset = _PreviousInitialByte(fCaretOffset);
|
||||
|
||||
@@ -3414,10 +3403,8 @@ BTextView::_HandleArrowKey(uint32 arrowKey, int32 modifiers)
|
||||
else if (fSelStart != fSelEnd && !shiftKeyDown)
|
||||
fCaretOffset = fSelEnd;
|
||||
else {
|
||||
if (optionKeyDown)
|
||||
if ((commandKeyDown || optionKeyDown) && !controlKeyDown)
|
||||
fCaretOffset = _NextWordEnd(fCaretOffset);
|
||||
else if (commandKeyDown || controlKeyDown)
|
||||
fCaretOffset = _NextLineEnd(fCaretOffset);
|
||||
else
|
||||
fCaretOffset = _NextInitialByte(fCaretOffset);
|
||||
|
||||
@@ -3444,9 +3431,9 @@ BTextView::_HandleArrowKey(uint32 arrowKey, int32 modifiers)
|
||||
else if (fSelStart != fSelEnd && !shiftKeyDown)
|
||||
fCaretOffset = fSelStart;
|
||||
else {
|
||||
if (optionKeyDown) {
|
||||
if (optionKeyDown && !commandKeyDown && !controlKeyDown)
|
||||
fCaretOffset = _PreviousLineStart(fCaretOffset);
|
||||
} else if (commandKeyDown || controlKeyDown) {
|
||||
else if (commandKeyDown && !optionKeyDown && !controlKeyDown) {
|
||||
_ScrollTo(0, 0);
|
||||
fCaretOffset = 0;
|
||||
} else {
|
||||
@@ -3488,9 +3475,9 @@ BTextView::_HandleArrowKey(uint32 arrowKey, int32 modifiers)
|
||||
else if (fSelStart != fSelEnd && !shiftKeyDown)
|
||||
fCaretOffset = fSelEnd;
|
||||
else {
|
||||
if (optionKeyDown) {
|
||||
if (optionKeyDown && !commandKeyDown && !controlKeyDown)
|
||||
fCaretOffset = _NextLineEnd(fCaretOffset);
|
||||
} else if (commandKeyDown || controlKeyDown) {
|
||||
else if (commandKeyDown && !optionKeyDown && !controlKeyDown) {
|
||||
_ScrollTo(0, fTextRect.bottom + fLayoutData->bottomInset);
|
||||
fCaretOffset = fText->Length();
|
||||
} else {
|
||||
@@ -3551,14 +3538,9 @@ BTextView::_HandleDelete(int32 modifiers)
|
||||
bool optionKeyDown = (modifiers & B_OPTION_KEY) != 0;
|
||||
bool commandKeyDown = (modifiers & B_COMMAND_KEY) != 0;
|
||||
|
||||
if (optionKeyDown) {
|
||||
// delete next word with option held down
|
||||
if ((commandKeyDown || optionKeyDown) && !controlKeyDown) {
|
||||
fSelStart = fCaretOffset;
|
||||
fSelEnd = _NextWordEnd(fCaretOffset) + 1;
|
||||
} else if (commandKeyDown && !controlKeyDown) {
|
||||
// delete to end of line with command held down
|
||||
fSelStart = fCaretOffset;
|
||||
fSelEnd = _NextLineEnd(fCaretOffset);
|
||||
}
|
||||
|
||||
if (fUndo) {
|
||||
@@ -5238,237 +5220,163 @@ BTextView::_Activate()
|
||||
if (Bounds().Contains(where))
|
||||
_TrackMouse(where, NULL);
|
||||
|
||||
// bail out if not connected to app server
|
||||
if (Window() == NULL)
|
||||
return;
|
||||
if (Window() != NULL) {
|
||||
BMessage* message;
|
||||
|
||||
// Define alternate shorcuts for Windows/Linux mode, these shortcuts
|
||||
// may be already be taken by application shortcuts.
|
||||
if (!Window()->HasShortcut(B_LEFT_ARROW, B_COMMAND_KEY)
|
||||
&& !Window()->HasShortcut(B_RIGHT_ARROW, B_COMMAND_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_LEFT_ARROW);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_LEFT_ARROW, B_COMMAND_KEY, message, this);
|
||||
|
||||
BMessage* message;
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_RIGHT_ARROW);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_RIGHT_ARROW, B_COMMAND_KEY, message, this);
|
||||
|
||||
// set Option+Left/Right for word-wise navigation
|
||||
if (!Window()->HasShortcut(B_LEFT_ARROW, B_NO_COMMAND_KEY | B_OPTION_KEY)
|
||||
&& !Window()->HasShortcut(B_RIGHT_ARROW, B_NO_COMMAND_KEY | B_OPTION_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_LEFT_ARROW);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY);
|
||||
Window()->AddShortcut(B_LEFT_ARROW, B_NO_COMMAND_KEY | B_OPTION_KEY, message, this);
|
||||
fInstalledNavigateCommandWordwiseShortcuts = true;
|
||||
}
|
||||
if (!Window()->HasShortcut(B_LEFT_ARROW, B_COMMAND_KEY | B_SHIFT_KEY)
|
||||
&& !Window()->HasShortcut(B_RIGHT_ARROW,
|
||||
B_COMMAND_KEY | B_SHIFT_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_LEFT_ARROW);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_LEFT_ARROW, B_COMMAND_KEY | B_SHIFT_KEY,
|
||||
message, this);
|
||||
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_RIGHT_ARROW);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY);
|
||||
Window()->AddShortcut(B_RIGHT_ARROW, B_OPTION_KEY, message, this);
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_RIGHT_ARROW);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_RIGHT_ARROW, B_COMMAND_KEY | B_SHIFT_KEY,
|
||||
message, this);
|
||||
|
||||
fInstalledNavigateOptionWordwiseShortcuts = true;
|
||||
}
|
||||
fInstalledSelectCommandWordwiseShortcuts = true;
|
||||
}
|
||||
if (!Window()->HasShortcut(B_DELETE, B_COMMAND_KEY)
|
||||
&& !Window()->HasShortcut(B_BACKSPACE, B_COMMAND_KEY)) {
|
||||
message = new BMessage(kMsgRemoveWord);
|
||||
message->AddInt32("key", B_DELETE);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_DELETE, B_COMMAND_KEY, message, this);
|
||||
|
||||
// set Shift+Option+Left/Right for word-wise selection
|
||||
if (!Window()->HasShortcut(B_LEFT_ARROW, B_NO_COMMAND_KEY | B_OPTION_KEY | B_SHIFT_KEY)
|
||||
&& !Window()->HasShortcut(B_RIGHT_ARROW, B_NO_COMMAND_KEY | B_OPTION_KEY | B_SHIFT_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_LEFT_ARROW);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_LEFT_ARROW, B_NO_COMMAND_KEY | B_OPTION_KEY | B_SHIFT_KEY, message,
|
||||
this);
|
||||
message = new BMessage(kMsgRemoveWord);
|
||||
message->AddInt32("key", B_BACKSPACE);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_BACKSPACE, B_COMMAND_KEY, message, this);
|
||||
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_RIGHT_ARROW);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_RIGHT_ARROW, B_NO_COMMAND_KEY | B_OPTION_KEY | B_SHIFT_KEY, message,
|
||||
this);
|
||||
fInstalledRemoveCommandWordwiseShortcuts = true;
|
||||
}
|
||||
|
||||
fInstalledSelectOptionWordwiseShortcuts = true;
|
||||
}
|
||||
if (!Window()->HasShortcut(B_LEFT_ARROW, B_OPTION_KEY)
|
||||
&& !Window()->HasShortcut(B_RIGHT_ARROW, B_OPTION_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_LEFT_ARROW);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY);
|
||||
Window()->AddShortcut(B_LEFT_ARROW, B_OPTION_KEY, message, this);
|
||||
|
||||
// set Command+Delete for line-wise deletion
|
||||
if (!Window()->HasShortcut(B_DELETE, B_COMMAND_KEY)
|
||||
&& !Window()->HasShortcut(B_BACKSPACE, B_COMMAND_KEY)) {
|
||||
message = new BMessage(kMsgRemoveWord);
|
||||
message->AddInt32("key", B_DELETE);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_DELETE, B_COMMAND_KEY, message, this);
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_RIGHT_ARROW);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY);
|
||||
Window()->AddShortcut(B_RIGHT_ARROW, B_OPTION_KEY, message, this);
|
||||
|
||||
message = new BMessage(kMsgRemoveWord);
|
||||
message->AddInt32("key", B_BACKSPACE);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_BACKSPACE, B_COMMAND_KEY, message, this);
|
||||
fInstalledNavigateOptionWordwiseShortcuts = true;
|
||||
}
|
||||
if (!Window()->HasShortcut(B_LEFT_ARROW, B_OPTION_KEY | B_SHIFT_KEY)
|
||||
&& !Window()->HasShortcut(B_RIGHT_ARROW,
|
||||
B_OPTION_KEY | B_SHIFT_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_LEFT_ARROW);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_LEFT_ARROW, B_OPTION_KEY | B_SHIFT_KEY,
|
||||
message, this);
|
||||
|
||||
fInstalledRemoveCommandLinewiseShortcuts = true;
|
||||
}
|
||||
// set Option+Delete for word-wise deletion
|
||||
if (!Window()->HasShortcut(B_DELETE, B_NO_COMMAND_KEY | B_OPTION_KEY)
|
||||
&& !Window()->HasShortcut(B_BACKSPACE, B_NO_COMMAND_KEY | B_OPTION_KEY)) {
|
||||
message = new BMessage(kMsgRemoveWord);
|
||||
message->AddInt32("key", B_DELETE);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY);
|
||||
Window()->AddShortcut(B_DELETE, B_NO_COMMAND_KEY | B_OPTION_KEY, message, this);
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_RIGHT_ARROW);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_RIGHT_ARROW, B_OPTION_KEY | B_SHIFT_KEY,
|
||||
message, this);
|
||||
|
||||
message = new BMessage(kMsgRemoveWord);
|
||||
message->AddInt32("key", B_BACKSPACE);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY);
|
||||
Window()->AddShortcut(B_BACKSPACE, B_NO_COMMAND_KEY | B_OPTION_KEY, message, this);
|
||||
fInstalledSelectOptionWordwiseShortcuts = true;
|
||||
}
|
||||
if (!Window()->HasShortcut(B_DELETE, B_OPTION_KEY)
|
||||
&& !Window()->HasShortcut(B_BACKSPACE, B_OPTION_KEY)) {
|
||||
message = new BMessage(kMsgRemoveWord);
|
||||
message->AddInt32("key", B_DELETE);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY);
|
||||
Window()->AddShortcut(B_DELETE, B_OPTION_KEY, message, this);
|
||||
|
||||
fInstalledRemoveOptionWordwiseShortcuts = true;
|
||||
}
|
||||
message = new BMessage(kMsgRemoveWord);
|
||||
message->AddInt32("key", B_BACKSPACE);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY);
|
||||
Window()->AddShortcut(B_BACKSPACE, B_OPTION_KEY, message, this);
|
||||
|
||||
// set Command+Left/Right to navigate to the beginning and end of a line
|
||||
if (!Window()->HasShortcut(B_LEFT_ARROW, B_COMMAND_KEY)
|
||||
&& !Window()->HasShortcut(B_RIGHT_ARROW, B_COMMAND_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_LEFT_ARROW);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_LEFT_ARROW, B_COMMAND_KEY, message, this);
|
||||
fInstalledRemoveOptionWordwiseShortcuts = true;
|
||||
}
|
||||
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_RIGHT_ARROW);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_RIGHT_ARROW, B_COMMAND_KEY, message, this);
|
||||
if (!Window()->HasShortcut(B_UP_ARROW, B_OPTION_KEY)
|
||||
&& !Window()->HasShortcut(B_DOWN_ARROW, B_OPTION_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_UP_ARROW);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY);
|
||||
Window()->AddShortcut(B_UP_ARROW, B_OPTION_KEY, message, this);
|
||||
|
||||
fInstalledNavigateCommandHorizontalLinewiseShortcuts = true;
|
||||
}
|
||||
// set Control+Left/Right alternate for Win/Linux mode
|
||||
if (!Window()->HasShortcut(B_LEFT_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY)
|
||||
&& !Window()->HasShortcut(B_RIGHT_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_LEFT_ARROW);
|
||||
message->AddInt32("modifiers", B_CONTROL_KEY);
|
||||
Window()->AddShortcut(B_LEFT_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY, message, this);
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_DOWN_ARROW);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY);
|
||||
Window()->AddShortcut(B_DOWN_ARROW, B_OPTION_KEY, message, this);
|
||||
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_RIGHT_ARROW);
|
||||
message->AddInt32("modifiers", B_CONTROL_KEY);
|
||||
Window()->AddShortcut(B_RIGHT_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY, message, this);
|
||||
fInstalledNavigateOptionLinewiseShortcuts = true;
|
||||
}
|
||||
if (!Window()->HasShortcut(B_UP_ARROW, B_OPTION_KEY | B_SHIFT_KEY)
|
||||
&& !Window()->HasShortcut(B_DOWN_ARROW,
|
||||
B_OPTION_KEY | B_SHIFT_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_UP_ARROW);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_UP_ARROW, B_OPTION_KEY | B_SHIFT_KEY,
|
||||
message, this);
|
||||
|
||||
fInstalledNavigateControlHorizontalLinewiseShortcuts = true;
|
||||
}
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_DOWN_ARROW);
|
||||
message->AddInt32("modifiers", B_OPTION_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_DOWN_ARROW, B_OPTION_KEY | B_SHIFT_KEY,
|
||||
message, this);
|
||||
|
||||
// set Command+Up/Down to navigate to the beginning and end of a line
|
||||
if (!Window()->HasShortcut(B_UP_ARROW, B_COMMAND_KEY)
|
||||
&& !Window()->HasShortcut(B_DOWN_ARROW, B_COMMAND_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_UP_ARROW);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_UP_ARROW, B_COMMAND_KEY, message, this);
|
||||
fInstalledSelectOptionLinewiseShortcuts = true;
|
||||
}
|
||||
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_DOWN_ARROW);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY, message, this);
|
||||
if (!Window()->HasShortcut(B_HOME, B_COMMAND_KEY)
|
||||
&& !Window()->HasShortcut(B_END, B_COMMAND_KEY)) {
|
||||
message = new BMessage(kMsgNavigatePage);
|
||||
message->AddInt32("key", B_HOME);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_HOME, B_COMMAND_KEY, message, this);
|
||||
|
||||
fInstalledNavigateCommandVerticalLinewiseShortcuts = true;
|
||||
}
|
||||
// set Control+Up/Down alternative to Win/Linux mode
|
||||
if (!Window()->HasShortcut(B_UP_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY)
|
||||
&& !Window()->HasShortcut(B_DOWN_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_UP_ARROW);
|
||||
message->AddInt32("modifiers", B_CONTROL_KEY);
|
||||
Window()->AddShortcut(B_UP_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY, message, this);
|
||||
message = new BMessage(kMsgNavigatePage);
|
||||
message->AddInt32("key", B_END);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_END, B_COMMAND_KEY, message, this);
|
||||
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_DOWN_ARROW);
|
||||
message->AddInt32("modifiers", B_CONTROL_KEY);
|
||||
Window()->AddShortcut(B_DOWN_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY, message, this);
|
||||
fInstalledNavigateHomeEndDocwiseShortcuts = true;
|
||||
}
|
||||
if (!Window()->HasShortcut(B_HOME, B_COMMAND_KEY | B_SHIFT_KEY)
|
||||
&& !Window()->HasShortcut(B_END, B_COMMAND_KEY | B_SHIFT_KEY)) {
|
||||
message = new BMessage(kMsgNavigatePage);
|
||||
message->AddInt32("key", B_HOME);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_HOME, B_COMMAND_KEY | B_SHIFT_KEY,
|
||||
message, this);
|
||||
|
||||
fInstalledNavigateControlVerticalLinewiseShortcuts = true;
|
||||
}
|
||||
message = new BMessage(kMsgNavigatePage);
|
||||
message->AddInt32("key", B_END);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_END, B_COMMAND_KEY | B_SHIFT_KEY,
|
||||
message, this);
|
||||
|
||||
// set Shift+Command+Left/Right to select to the beginning/end of line
|
||||
if (!Window()->HasShortcut(B_LEFT_ARROW, B_COMMAND_KEY | B_SHIFT_KEY)
|
||||
&& !Window()->HasShortcut(B_RIGHT_ARROW, B_COMMAND_KEY | B_SHIFT_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_LEFT_ARROW);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_LEFT_ARROW, B_COMMAND_KEY | B_SHIFT_KEY, message, this);
|
||||
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_RIGHT_ARROW);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_RIGHT_ARROW, B_COMMAND_KEY | B_SHIFT_KEY, message, this);
|
||||
|
||||
fInstalledSelectCommandHorizontalLinewiseShortcuts = true;
|
||||
}
|
||||
// set Shift+Control+Left/Right alternate for Win/Linux mode
|
||||
if (!Window()->HasShortcut(B_LEFT_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY)
|
||||
&& !Window()->HasShortcut(B_RIGHT_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_LEFT_ARROW);
|
||||
message->AddInt32("modifiers", B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_LEFT_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY, message,
|
||||
this);
|
||||
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_RIGHT_ARROW);
|
||||
message->AddInt32("modifiers", B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_RIGHT_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY,
|
||||
message, this);
|
||||
|
||||
fInstalledSelectControlHorizontalLinewiseShortcuts = true;
|
||||
}
|
||||
|
||||
// set Shift+Command+Up/Down to select to the beginning/end of line
|
||||
if (!Window()->HasShortcut(B_UP_ARROW, B_COMMAND_KEY | B_SHIFT_KEY)
|
||||
&& !Window()->HasShortcut(B_DOWN_ARROW, B_COMMAND_KEY | B_SHIFT_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_UP_ARROW);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_SHIFT_KEY, message, this);
|
||||
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_DOWN_ARROW);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY | B_SHIFT_KEY, message, this);
|
||||
|
||||
fInstalledSelectCommandVerticalLinewiseShortcuts = true;
|
||||
}
|
||||
// set Shift+Control+Up/Down alternate for Win/Linux mode
|
||||
if (!Window()->HasShortcut(B_UP_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY)
|
||||
&& !Window()->HasShortcut(B_DOWN_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY)) {
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_UP_ARROW);
|
||||
message->AddInt32("modifiers", B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_UP_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY, message,
|
||||
this);
|
||||
|
||||
message = new BMessage(kMsgNavigateArrow);
|
||||
message->AddInt32("key", B_DOWN_ARROW);
|
||||
message->AddInt32("modifiers", B_CONTROL_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_DOWN_ARROW, B_CONTROL_KEY | B_SHIFT_KEY, message, this);
|
||||
|
||||
fInstalledSelectControlVerticalLinewiseShortcuts = true;
|
||||
}
|
||||
|
||||
// set Command+Home/End for doc-wise navigation
|
||||
if (!Window()->HasShortcut(B_HOME, B_COMMAND_KEY)
|
||||
&& !Window()->HasShortcut(B_END, B_COMMAND_KEY)) {
|
||||
message = new BMessage(kMsgNavigatePage);
|
||||
message->AddInt32("key", B_HOME);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_HOME, B_COMMAND_KEY, message, this);
|
||||
|
||||
message = new BMessage(kMsgNavigatePage);
|
||||
message->AddInt32("key", B_END);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY);
|
||||
Window()->AddShortcut(B_END, B_COMMAND_KEY, message, this);
|
||||
|
||||
fInstalledNavigateHomeEndDocwiseShortcuts = true;
|
||||
}
|
||||
|
||||
// set Shift+Commmand Home/End for doc-wise selection
|
||||
if (!Window()->HasShortcut(B_HOME, B_COMMAND_KEY | B_SHIFT_KEY)
|
||||
&& !Window()->HasShortcut(B_END, B_COMMAND_KEY | B_SHIFT_KEY)) {
|
||||
message = new BMessage(kMsgNavigatePage);
|
||||
message->AddInt32("key", B_HOME);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_HOME, B_COMMAND_KEY | B_SHIFT_KEY, message, this);
|
||||
|
||||
message = new BMessage(kMsgNavigatePage);
|
||||
message->AddInt32("key", B_END);
|
||||
message->AddInt32("modifiers", B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->AddShortcut(B_END, B_COMMAND_KEY | B_SHIFT_KEY, message, this);
|
||||
|
||||
fInstalledSelectHomeEndDocwiseShortcuts = true;
|
||||
fInstalledSelectHomeEndDocwiseShortcuts = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5488,84 +5396,61 @@ BTextView::_Deactivate()
|
||||
} else
|
||||
_HideCaret();
|
||||
|
||||
// bail out if not connected to app server
|
||||
if (Window() == NULL)
|
||||
return;
|
||||
if (Window() != NULL) {
|
||||
if (fInstalledNavigateCommandWordwiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_LEFT_ARROW, B_COMMAND_KEY);
|
||||
Window()->RemoveShortcut(B_RIGHT_ARROW, B_COMMAND_KEY);
|
||||
fInstalledNavigateCommandWordwiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledSelectCommandWordwiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_LEFT_ARROW, B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->RemoveShortcut(B_RIGHT_ARROW,
|
||||
B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
fInstalledSelectCommandWordwiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledRemoveCommandWordwiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_DELETE, B_COMMAND_KEY);
|
||||
Window()->RemoveShortcut(B_BACKSPACE, B_COMMAND_KEY);
|
||||
fInstalledRemoveCommandWordwiseShortcuts = false;
|
||||
}
|
||||
|
||||
// word-wise shortcuts use option or command+control
|
||||
if (fInstalledNavigateOptionWordwiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_LEFT_ARROW, B_NO_COMMAND_KEY | B_OPTION_KEY);
|
||||
Window()->RemoveShortcut(B_RIGHT_ARROW, B_NO_COMMAND_KEY | B_OPTION_KEY);
|
||||
fInstalledNavigateOptionWordwiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledSelectOptionWordwiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_LEFT_ARROW, B_NO_COMMAND_KEY | B_OPTION_KEY | B_SHIFT_KEY);
|
||||
Window()->RemoveShortcut(B_RIGHT_ARROW, B_NO_COMMAND_KEY | B_OPTION_KEY | B_SHIFT_KEY);
|
||||
fInstalledSelectOptionWordwiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledRemoveCommandLinewiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_DELETE, B_COMMAND_KEY);
|
||||
Window()->RemoveShortcut(B_BACKSPACE, B_COMMAND_KEY);
|
||||
fInstalledRemoveCommandLinewiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledRemoveOptionWordwiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_DELETE, B_NO_COMMAND_KEY | B_OPTION_KEY);
|
||||
Window()->RemoveShortcut(B_BACKSPACE, B_NO_COMMAND_KEY | B_OPTION_KEY);
|
||||
fInstalledRemoveOptionWordwiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledNavigateOptionWordwiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_LEFT_ARROW, B_OPTION_KEY);
|
||||
Window()->RemoveShortcut(B_RIGHT_ARROW, B_OPTION_KEY);
|
||||
fInstalledNavigateOptionWordwiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledSelectOptionWordwiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_LEFT_ARROW, B_OPTION_KEY | B_SHIFT_KEY);
|
||||
Window()->RemoveShortcut(B_RIGHT_ARROW, B_OPTION_KEY | B_SHIFT_KEY);
|
||||
fInstalledSelectOptionWordwiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledRemoveOptionWordwiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_DELETE, B_OPTION_KEY);
|
||||
Window()->RemoveShortcut(B_BACKSPACE, B_OPTION_KEY);
|
||||
fInstalledRemoveOptionWordwiseShortcuts = false;
|
||||
}
|
||||
|
||||
// line-wise shortcuts use command or control
|
||||
if (fInstalledNavigateCommandHorizontalLinewiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_LEFT_ARROW, B_COMMAND_KEY);
|
||||
Window()->RemoveShortcut(B_RIGHT_ARROW, B_COMMAND_KEY);
|
||||
fInstalledNavigateCommandHorizontalLinewiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledNavigateCommandVerticalLinewiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_UP_ARROW, B_COMMAND_KEY);
|
||||
Window()->RemoveShortcut(B_DOWN_ARROW, B_COMMAND_KEY);
|
||||
fInstalledNavigateCommandVerticalLinewiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledNavigateControlHorizontalLinewiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_LEFT_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY);
|
||||
Window()->RemoveShortcut(B_RIGHT_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY);
|
||||
fInstalledNavigateControlHorizontalLinewiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledNavigateControlVerticalLinewiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_UP_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY);
|
||||
Window()->RemoveShortcut(B_DOWN_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY);
|
||||
fInstalledNavigateControlVerticalLinewiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledSelectCommandHorizontalLinewiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_LEFT_ARROW, B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->RemoveShortcut(B_RIGHT_ARROW, B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
fInstalledSelectCommandHorizontalLinewiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledSelectCommandVerticalLinewiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_UP_ARROW, B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->RemoveShortcut(B_DOWN_ARROW, B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
fInstalledSelectCommandVerticalLinewiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledSelectControlHorizontalLinewiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_LEFT_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY);
|
||||
Window()->RemoveShortcut(B_RIGHT_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY);
|
||||
fInstalledSelectControlHorizontalLinewiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledSelectControlVerticalLinewiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_UP_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY);
|
||||
Window()->RemoveShortcut(B_DOWN_ARROW, B_NO_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY);
|
||||
fInstalledSelectControlVerticalLinewiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledNavigateOptionLinewiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_UP_ARROW, B_OPTION_KEY);
|
||||
Window()->RemoveShortcut(B_DOWN_ARROW, B_OPTION_KEY);
|
||||
fInstalledNavigateOptionLinewiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledSelectOptionLinewiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_UP_ARROW, B_OPTION_KEY | B_SHIFT_KEY);
|
||||
Window()->RemoveShortcut(B_DOWN_ARROW, B_OPTION_KEY | B_SHIFT_KEY);
|
||||
fInstalledSelectOptionLinewiseShortcuts = false;
|
||||
}
|
||||
|
||||
// doc-wise shortcuts use command
|
||||
if (fInstalledNavigateHomeEndDocwiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_HOME, B_COMMAND_KEY);
|
||||
Window()->RemoveShortcut(B_END, B_COMMAND_KEY);
|
||||
fInstalledNavigateHomeEndDocwiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledSelectHomeEndDocwiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_HOME, B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->RemoveShortcut(B_END, B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
fInstalledSelectHomeEndDocwiseShortcuts = false;
|
||||
if (fInstalledNavigateHomeEndDocwiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_HOME, B_COMMAND_KEY);
|
||||
Window()->RemoveShortcut(B_END, B_COMMAND_KEY);
|
||||
fInstalledNavigateHomeEndDocwiseShortcuts = false;
|
||||
}
|
||||
if (fInstalledSelectHomeEndDocwiseShortcuts) {
|
||||
Window()->RemoveShortcut(B_HOME, B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
Window()->RemoveShortcut(B_END, B_COMMAND_KEY | B_SHIFT_KEY);
|
||||
fInstalledSelectHomeEndDocwiseShortcuts = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user