Ticket #6885: textview_paste_26102011.patch
File textview_paste_26102011.patch, 2.3 KB (added by , 12 years ago) |
---|
-
src/kits/interface/TextView.cpp
1447 1447 B_MIME_TYPE, (const void **)&runArray, &runLen); 1448 1448 } 1449 1449 1450 _FilterDisallowedChars((char*)text, len, runArray); 1451 1452 if (len < 1) { 1453 beep(); 1454 clipboard->Unlock(); 1455 return; 1456 } 1457 1450 1458 if (fUndo) { 1451 1459 delete fUndo; 1452 1460 fUndo = new PasteUndoBuffer(this, text, len, runArray, … … 4805 4813 inMessage->FindData("application/x-vnd.Be-text_run_array", 4806 4814 B_MIME_TYPE, (const void **)&runArray, &runLen); 4807 4815 4816 _FilterDisallowedChars((char*)text, dataLen, runArray); 4817 4818 if (dataLen < 1) { 4819 beep(); 4820 return true; 4821 } 4822 4808 4823 if (fUndo) { 4809 4824 delete fUndo; 4810 4825 fUndo = new DropUndoBuffer(this, text, dataLen, runArray, … … 5574 5589 int32 start; 5575 5590 int32 finish; 5576 5591 GetSelection(&start, &finish); 5577 5592 5578 5593 bool canEdit = IsEditable(); 5579 5594 int32 length = TextLength(); 5580 5595 … … 5602 5617 menu->Go(where, true, true, true); 5603 5618 } 5604 5619 5620 5621 void 5622 BTextView::_FilterDisallowedChars(char* text, int32& len, 5623 text_run_array* runArray) 5624 { 5625 if (!fDisallowedChars) 5626 return; 5627 5628 if (fDisallowedChars->IsEmpty() || !text) 5629 return; 5630 5631 int32 s = 0; 5632 if (runArray) { 5633 int32 remNext = 0; 5634 5635 for (int i = 0; i < runArray->count; i++) { 5636 runArray->runs[i].offset -= remNext; 5637 while (s < runArray->runs[i].offset && s < len) { 5638 if (fDisallowedChars->HasItem((void*)text[s])) { 5639 memmove(text + s, text + s + 1, len - s - 1); 5640 len--; 5641 runArray->runs[i].offset--; 5642 remNext++; 5643 } else 5644 s++; 5645 } 5646 } 5647 } 5648 5649 while (s < len) { 5650 if (fDisallowedChars->HasItem((void*)text[s])) { 5651 memmove(text + s, text + s + 1, len - s - 1); 5652 len--; 5653 } else 5654 s++; 5655 } 5656 } 5657 5605 5658 // #pragma mark - BTextView::TextTrackState 5606 5659 5607 5660 -
headers/os/interface/TextView.h
411 411 412 412 void _ShowContextMenu(BPoint where); 413 413 414 void _FilterDisallowedChars(char* text, int32& len, 415 text_run_array* runArray); 416 414 417 private: 415 418 BPrivate::TextGapBuffer* fText; 416 419 LineBuffer* fLines;