fixed word by word selection

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18943 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2006-09-26 15:07:19 +00:00
parent 6343dc9855
commit 9205b41148
+16 -20
View File
@@ -14,7 +14,6 @@
// - Finish documenting this class // - Finish documenting this class
// - Consider using BObjectList instead of BList // - Consider using BObjectList instead of BList
// for disallowed characters (it would remove a lot of reinterpret_casts) // for disallowed characters (it would remove a lot of reinterpret_casts)
// - Asynchronous mouse tracking
// - Check for correctness and possible optimizations the calls to Refresh(), // - Check for correctness and possible optimizations the calls to Refresh(),
// to refresh only changed parts of text (currently we often redraw the whole text) // to refresh only changed parts of text (currently we often redraw the whole text)
@@ -3799,6 +3798,21 @@ BTextView::PerformMouseMoved(BPoint where, uint32 code)
int32 oldOffset = fTrackingMouse->anchor; int32 oldOffset = fTrackingMouse->anchor;
int32 currentOffset = OffsetAt(where); int32 currentOffset = OffsetAt(where);
switch (fClickCount) {
case 0:
// triple click, select line by line
fTrackingMouse->selStart = (*fLines)[LineAt(fTrackingMouse->selStart)]->offset;
fTrackingMouse->selEnd = (*fLines)[LineAt(fTrackingMouse->selEnd) + 1]->offset;
break;
case 2:
// double click, select word by word
FindWord(currentOffset, &fTrackingMouse->selStart, &fTrackingMouse->selEnd);
break;
default:
// new click, select char by char
if (oldOffset < currentOffset) { if (oldOffset < currentOffset) {
fTrackingMouse->selStart = oldOffset; fTrackingMouse->selStart = oldOffset;
fTrackingMouse->selEnd = currentOffset; fTrackingMouse->selEnd = currentOffset;
@@ -3806,28 +3820,10 @@ BTextView::PerformMouseMoved(BPoint where, uint32 code)
fTrackingMouse->selStart = currentOffset; fTrackingMouse->selStart = currentOffset;
fTrackingMouse->selEnd = oldOffset; fTrackingMouse->selEnd = oldOffset;
} }
int32 start = fTrackingMouse->selStart;
int32 end = fTrackingMouse->selEnd;
switch (fClickCount) {
case 0:
// triple click, select line by line
start = (*fLines)[LineAt(start)]->offset;
end = (*fLines)[LineAt(end) + 1]->offset;
break;
case 2:
// double click, select word by word
FindWord(oldOffset, &start, &end);
break;
default:
// new click, select char by char
break; break;
} }
Select(start, end); Select(fTrackingMouse->selStart, fTrackingMouse->selEnd);
TrackMouse(where, NULL); TrackMouse(where, NULL);