When Clear() was called, an undo action was created even if undo was disabled. Fixed, and added a comment to it. Some more checks for NULL, some variable renaming.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10476 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2004-12-16 08:27:09 +00:00
parent 87f158f3f5
commit 0115269685
+22 -19
View File
@@ -1338,11 +1338,10 @@ BTextView::Copy(BClipboard *clipboard)
CancelInputMethod(); CancelInputMethod();
BMessage *clip = NULL;
if (clipboard->Lock()) { if (clipboard->Lock()) {
clipboard->Clear(); clipboard->Clear();
BMessage *clip = NULL;
if ((clip = clipboard->Data()) != NULL) { if ((clip = clipboard->Data()) != NULL) {
clip->AddData("text/plain", B_MIME_TYPE, Text() + fSelStart, clip->AddData("text/plain", B_MIME_TYPE, Text() + fSelStart,
fSelEnd - fSelStart); fSelEnd - fSelStart);
@@ -1370,10 +1369,8 @@ BTextView::Paste(BClipboard *clipboard)
CALLED(); CALLED();
CancelInputMethod(); CancelInputMethod();
BMessage *clip = NULL;
if (clipboard->Lock()) { if (clipboard->Lock()) {
clip = clipboard->Data(); BMessage *clip = clipboard->Data();
if (clip != NULL) { if (clip != NULL) {
const char *text = NULL; const char *text = NULL;
ssize_t len = 0; ssize_t len = 0;
@@ -1411,9 +1408,13 @@ BTextView::Clear()
{ {
CALLED(); CALLED();
delete fUndo; // We always check for fUndo != NULL (not only here),
fUndo = new _BClearUndoBuffer_(this); // because when fUndo is NULL, undo is deactivated.
if (fUndo) {
delete fUndo;
fUndo = new _BClearUndoBuffer_(this);
}
Delete(); Delete();
} }
@@ -2560,7 +2561,6 @@ BTextView::SetDoesUndo(bool undo)
{ {
if (undo && fUndo == NULL) if (undo && fUndo == NULL)
fUndo = new _BUndoBuffer_(this, B_UNDO_UNAVAILABLE); fUndo = new _BUndoBuffer_(this, B_UNDO_UNAVAILABLE);
else if (!undo && fUndo != NULL) { else if (!undo && fUndo != NULL) {
delete fUndo; delete fUndo;
fUndo = NULL; fUndo = NULL;
@@ -2808,10 +2808,12 @@ BTextView::GetDragParameters(BMessage *drag, BBitmap **bitmap,
int32 size = 0; int32 size = 0;
text_run_array *styles = RunArray(fSelStart, fSelEnd, &size); text_run_array *styles = RunArray(fSelStart, fSelEnd, &size);
drag->AddData("application/x-vnd.Be-text_run_array", B_MIME_TYPE, if (styles != NULL) {
styles, size); drag->AddData("application/x-vnd.Be-text_run_array", B_MIME_TYPE,
styles, size);
free(styles); free(styles);
}
if (bitmap != NULL) if (bitmap != NULL)
*bitmap = NULL; *bitmap = NULL;
@@ -3943,26 +3945,26 @@ void
BTextView::InitiateDrag() BTextView::InitiateDrag()
{ {
CALLED(); CALLED();
BMessage *drag = new BMessage(B_MIME_DATA); BMessage *message = new BMessage(B_MIME_DATA);
BBitmap *dragBitmap = NULL; BBitmap *dragBitmap = NULL;
BPoint bitmapPoint; BPoint bitmapPoint;
BHandler *dragHandler = NULL; BHandler *dragHandler = NULL;
GetDragParameters(drag, &dragBitmap, &bitmapPoint, &dragHandler); GetDragParameters(message, &dragBitmap, &bitmapPoint, &dragHandler);
SetViewCursor(B_CURSOR_SYSTEM_DEFAULT); SetViewCursor(B_CURSOR_SYSTEM_DEFAULT);
if (dragBitmap != NULL) if (dragBitmap != NULL)
DragMessage(drag, dragBitmap, bitmapPoint, dragHandler); DragMessage(message, dragBitmap, bitmapPoint, dragHandler);
else { else {
BRegion hiliteRgn; BRegion region;
GetTextRegion(fSelStart, fSelEnd, &hiliteRgn); GetTextRegion(fSelStart, fSelEnd, &region);
BRect bounds = Bounds(); BRect bounds = Bounds();
BRect dragRect = hiliteRgn.Frame(); BRect dragRect = region.Frame();
if (!bounds.Contains(dragRect)) if (!bounds.Contains(dragRect))
dragRect = bounds & dragRect; dragRect = bounds & dragRect;
DragMessage(drag, dragRect, dragHandler); DragMessage(message, dragRect, dragHandler);
} }
} }
@@ -4200,6 +4202,7 @@ BTextView::CharClassification(int32 offset) const
// japanese word breakers. // japanese word breakers.
// And what about other languages ? Isn't there a better way to check // And what about other languages ? Isn't there a better way to check
// for separator characters ? // for separator characters ?
// Andrew suggested to have a look at UnicodeBlockObject.h
switch (fText->RealCharAt(offset)) { switch (fText->RealCharAt(offset)) {
case B_SPACE: case B_SPACE:
case '_': case '_':