Now also send a selection update notice if the contents have changed.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6745 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -103,41 +103,50 @@ DataView::UpdateFromEditor(BMessage *message)
|
|||||||
if (fData == NULL)
|
if (fData == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fEditor.Lock()) {
|
BAutolock locker(fEditor);
|
||||||
fFileSize = fEditor.FileSize();
|
|
||||||
|
|
||||||
// get the range of the changes
|
fFileSize = fEditor.FileSize();
|
||||||
|
|
||||||
int32 start = 0, end = fDataSize - 1;
|
// get the range of the changes
|
||||||
off_t offset, size;
|
|
||||||
if (message != NULL
|
|
||||||
&& message->FindInt64("offset", &offset) == B_OK
|
|
||||||
&& message->FindInt64("size", &size) == B_OK) {
|
|
||||||
if (offset > fOffset + fDataSize
|
|
||||||
|| offset + size < fOffset) {
|
|
||||||
// the changes are not within our scope, so we can ignore them
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (offset > fOffset)
|
int32 start = 0, end = fDataSize - 1;
|
||||||
start = offset - fOffset;
|
off_t offset, size;
|
||||||
if (offset + size < fOffset + fDataSize)
|
if (message != NULL
|
||||||
end = offset + size - fOffset;
|
&& message->FindInt64("offset", &offset) == B_OK
|
||||||
|
&& message->FindInt64("size", &size) == B_OK) {
|
||||||
|
if (offset > fOffset + fDataSize
|
||||||
|
|| offset + size < fOffset) {
|
||||||
|
// the changes are not within our scope, so we can ignore them
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fOffset + fDataSize > fFileSize)
|
if (offset > fOffset)
|
||||||
fSizeInView = fFileSize - fOffset;
|
start = offset - fOffset;
|
||||||
else
|
if (offset + size < fOffset + fDataSize)
|
||||||
fSizeInView = fDataSize;
|
end = offset + size - fOffset;
|
||||||
|
}
|
||||||
|
|
||||||
const uint8 *data;
|
if (fOffset + fDataSize > fFileSize)
|
||||||
if (fEditor.GetViewBuffer(&data) == B_OK)
|
fSizeInView = fFileSize - fOffset;
|
||||||
// ToDo: copy only the relevant part
|
else
|
||||||
memcpy(fData, data, fDataSize);
|
fSizeInView = fDataSize;
|
||||||
|
|
||||||
fEditor.Unlock();
|
const uint8 *data;
|
||||||
|
if (fEditor.GetViewBuffer(&data) == B_OK)
|
||||||
|
// ToDo: copy only the relevant part
|
||||||
|
memcpy(fData, data, fDataSize);
|
||||||
|
|
||||||
InvalidateRange(start, end);
|
fEditor.Unlock();
|
||||||
|
|
||||||
|
InvalidateRange(start, end);
|
||||||
|
|
||||||
|
// we notify our selection listeners also if the
|
||||||
|
// data in the selection has changed
|
||||||
|
if (start <= fEnd && end >= fStart) {
|
||||||
|
BMessage update;
|
||||||
|
update.AddInt64("start", fStart);
|
||||||
|
update.AddInt64("end", fEnd);
|
||||||
|
SendNotices(kDataViewSelection, &update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user