* implemented wordwise navigation via control + arrow keys
* renamed _FindXXXWordBoundary() methods to _Previous/_NextWordBoundary() since the respective per-char methods are named this way * started to work on improving the behaviour of page-up/page-down git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30012 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -303,9 +303,6 @@ private:
|
|||||||
float* outAscent, float* outDescent,
|
float* outAscent, float* outDescent,
|
||||||
float* ioWidth);
|
float* ioWidth);
|
||||||
|
|
||||||
int32 _FindLeftWordBoundary(int32 offset);
|
|
||||||
int32 _FindRightWordBoundary(int32 offset);
|
|
||||||
|
|
||||||
float _StyledWidth(int32 fromOffset, int32 length,
|
float _StyledWidth(int32 fromOffset, int32 length,
|
||||||
float* outAscent = NULL,
|
float* outAscent = NULL,
|
||||||
float* outDescent = NULL) const;
|
float* outDescent = NULL) const;
|
||||||
@@ -327,10 +324,10 @@ private:
|
|||||||
|
|
||||||
void _DrawLines(int32 startLine, int32 endLine,
|
void _DrawLines(int32 startLine, int32 endLine,
|
||||||
int32 startOffset = -1, bool erase = false);
|
int32 startOffset = -1, bool erase = false);
|
||||||
void _RequestDrawLines(int32 startLine,
|
void _RequestDrawLines(int32 startLine,
|
||||||
int32 endLine, int32 startOffset = -1,
|
int32 endLine, int32 startOffset = -1,
|
||||||
bool erase = false);
|
bool erase = false);
|
||||||
|
|
||||||
void _DrawCaret(int32 offset);
|
void _DrawCaret(int32 offset);
|
||||||
void _ShowCaret();
|
void _ShowCaret();
|
||||||
void _HideCaret();
|
void _HideCaret();
|
||||||
@@ -369,6 +366,9 @@ private:
|
|||||||
int32 _NextInitialByte(int32 offset) const;
|
int32 _NextInitialByte(int32 offset) const;
|
||||||
int32 _PreviousInitialByte(int32 offset) const;
|
int32 _PreviousInitialByte(int32 offset) const;
|
||||||
|
|
||||||
|
int32 _PreviousWordBoundary(int32 offset);
|
||||||
|
int32 _NextWordBoundary(int32 offset);
|
||||||
|
|
||||||
bool _GetProperty(BMessage* specifier, int32 form,
|
bool _GetProperty(BMessage* specifier, int32 form,
|
||||||
const char* property, BMessage* reply);
|
const char* property, BMessage* reply);
|
||||||
bool _SetProperty(BMessage* specifier, int32 form,
|
bool _SetProperty(BMessage* specifier, int32 form,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
* Marc Flerackers ([email protected])
|
* Marc Flerackers ([email protected])
|
||||||
* Stefano Ceccherini ([email protected])
|
* Stefano Ceccherini ([email protected])
|
||||||
* Stephan Aßmus <[email protected]>
|
* Stephan Aßmus <[email protected]>
|
||||||
|
* Oliver Tappe <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! BTextView displays and manages styled text. */
|
/*! BTextView displays and manages styled text. */
|
||||||
@@ -1923,10 +1924,10 @@ void
|
|||||||
BTextView::FindWord(int32 inOffset, int32 *outFromOffset, int32 *outToOffset)
|
BTextView::FindWord(int32 inOffset, int32 *outFromOffset, int32 *outToOffset)
|
||||||
{
|
{
|
||||||
if (outFromOffset)
|
if (outFromOffset)
|
||||||
*outFromOffset = _FindLeftWordBoundary(inOffset);
|
*outFromOffset = _PreviousWordBoundary(inOffset);
|
||||||
|
|
||||||
if (outToOffset)
|
if (outToOffset)
|
||||||
*outToOffset = _FindRightWordBoundary(inOffset);
|
*outToOffset = _NextWordBoundary(inOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3178,38 +3179,42 @@ BTextView::_HandleArrowKey(uint32 inArrowKey)
|
|||||||
message->FindInt32("modifiers", &modifiers);
|
message->FindInt32("modifiers", &modifiers);
|
||||||
|
|
||||||
bool shiftDown = modifiers & B_SHIFT_KEY;
|
bool shiftDown = modifiers & B_SHIFT_KEY;
|
||||||
|
bool ctrlDown = modifiers & B_CONTROL_KEY;
|
||||||
|
|
||||||
int32 currentOffset = fClickOffset;
|
int32 currentOffset = fClickOffset;
|
||||||
switch (inArrowKey) {
|
switch (inArrowKey) {
|
||||||
case B_LEFT_ARROW:
|
case B_LEFT_ARROW:
|
||||||
if (shiftDown) {
|
if (fSelStart != fSelEnd && !shiftDown)
|
||||||
fClickOffset = _PreviousInitialByte(fClickOffset);
|
fClickOffset = fSelStart;
|
||||||
if (fClickOffset != currentOffset) {
|
else {
|
||||||
|
fClickOffset
|
||||||
|
= ctrlDown
|
||||||
|
? _PreviousWordBoundary(fClickOffset - 1)
|
||||||
|
: _PreviousInitialByte(fClickOffset);
|
||||||
|
if (shiftDown && fClickOffset != currentOffset) {
|
||||||
if (fClickOffset >= fSelStart)
|
if (fClickOffset >= fSelStart)
|
||||||
selEnd = fClickOffset;
|
selEnd = fClickOffset;
|
||||||
else
|
else
|
||||||
selStart = fClickOffset;
|
selStart = fClickOffset;
|
||||||
}
|
}
|
||||||
} else if (fSelStart != fSelEnd)
|
}
|
||||||
fClickOffset = fSelStart;
|
|
||||||
else
|
|
||||||
fClickOffset = _PreviousInitialByte(fSelStart);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_RIGHT_ARROW:
|
case B_RIGHT_ARROW:
|
||||||
if (shiftDown) {
|
if (fSelStart != fSelEnd && !shiftDown)
|
||||||
fClickOffset = _NextInitialByte(fClickOffset);
|
fClickOffset = fSelEnd;
|
||||||
if (fClickOffset != currentOffset) {
|
else {
|
||||||
|
fClickOffset
|
||||||
|
= ctrlDown
|
||||||
|
? _NextWordBoundary(fClickOffset)
|
||||||
|
: _NextInitialByte(fClickOffset);
|
||||||
|
if (shiftDown && fClickOffset != currentOffset) {
|
||||||
if (fClickOffset <= fSelEnd)
|
if (fClickOffset <= fSelEnd)
|
||||||
selStart = fClickOffset;
|
selStart = fClickOffset;
|
||||||
else
|
else
|
||||||
selEnd = fClickOffset;
|
selEnd = fClickOffset;
|
||||||
}
|
}
|
||||||
} else if (fSelStart != fSelEnd)
|
}
|
||||||
fClickOffset = fSelEnd;
|
|
||||||
else
|
|
||||||
fClickOffset = _NextInitialByte(fSelEnd);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_UP_ARROW:
|
case B_UP_ARROW:
|
||||||
@@ -3392,7 +3397,7 @@ BTextView::_HandlePageKey(uint32 inPageKey)
|
|||||||
BPoint currentPos = PointAt(fClickOffset);
|
BPoint currentPos = PointAt(fClickOffset);
|
||||||
|
|
||||||
currentPos.y += Bounds().Height();
|
currentPos.y += Bounds().Height();
|
||||||
fClickOffset = OffsetAt(LineAt(currentPos) + 1);
|
fClickOffset = OffsetAt(LineAt(currentPos));
|
||||||
|
|
||||||
if (shiftDown) {
|
if (shiftDown) {
|
||||||
if (fClickOffset >= fSelEnd) {
|
if (fClickOffset >= fSelEnd) {
|
||||||
@@ -3803,7 +3808,7 @@ BTextView::_FindLineBreak(int32 fromOffset, float *outAscent, float *outDescent,
|
|||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
BTextView::_FindLeftWordBoundary(int32 offset)
|
BTextView::_PreviousWordBoundary(int32 offset)
|
||||||
{
|
{
|
||||||
uint32 charType = _CharClassification(offset);
|
uint32 charType = _CharClassification(offset);
|
||||||
int32 previous;
|
int32 previous;
|
||||||
@@ -3819,7 +3824,7 @@ BTextView::_FindLeftWordBoundary(int32 offset)
|
|||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
BTextView::_FindRightWordBoundary(int32 offset)
|
BTextView::_NextWordBoundary(int32 offset)
|
||||||
{
|
{
|
||||||
uint32 charType = _CharClassification(offset);
|
uint32 charType = _CharClassification(offset);
|
||||||
int32 textLen = TextLength();
|
int32 textLen = TextLength();
|
||||||
@@ -4338,17 +4343,17 @@ BTextView::_PerformMouseMoved(BPoint where, uint32 code)
|
|||||||
case 2:
|
case 2:
|
||||||
// double click, extend selection wordwise
|
// double click, extend selection wordwise
|
||||||
if (currentOffset <= fTrackingMouse->anchor) {
|
if (currentOffset <= fTrackingMouse->anchor) {
|
||||||
fTrackingMouse->selStart = _FindLeftWordBoundary(currentOffset);
|
fTrackingMouse->selStart = _PreviousWordBoundary(currentOffset);
|
||||||
fTrackingMouse->selEnd
|
fTrackingMouse->selEnd
|
||||||
= fTrackingMouse->shiftDown
|
= fTrackingMouse->shiftDown
|
||||||
? fSelEnd
|
? fSelEnd
|
||||||
: _FindRightWordBoundary(fTrackingMouse->anchor);
|
: _NextWordBoundary(fTrackingMouse->anchor);
|
||||||
} else {
|
} else {
|
||||||
fTrackingMouse->selStart
|
fTrackingMouse->selStart
|
||||||
= fTrackingMouse->shiftDown
|
= fTrackingMouse->shiftDown
|
||||||
? fSelStart
|
? fSelStart
|
||||||
: _FindLeftWordBoundary(fTrackingMouse->anchor);
|
: _PreviousWordBoundary(fTrackingMouse->anchor);
|
||||||
fTrackingMouse->selEnd = _FindRightWordBoundary(currentOffset);
|
fTrackingMouse->selEnd = _NextWordBoundary(currentOffset);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user