Changeset 22129
- Timestamp:
- 08/31/07 03:39:18 (15 months ago)
- Location:
- haiku/trunk/src/kits/interface
- Files:
-
- 3 modified
-
TextView.cpp (modified) (13 diffs)
-
textview_support/TextGapBuffer.cpp (modified) (8 diffs)
-
textview_support/TextGapBuffer.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
haiku/trunk/src/kits/interface/TextView.cpp
r22095 r22129 774 774 switch (message->what) { 775 775 case B_CUT: 776 Cut(be_clipboard); 776 if (!IsTypingHidden()) 777 Cut(be_clipboard); 778 else 779 beep(); 777 780 break; 778 781 779 782 case B_COPY: 780 Copy(be_clipboard); 783 if (!IsTypingHidden()) 784 Copy(be_clipboard); 785 else 786 beep(); 781 787 break; 782 788 … … 846 852 break; 847 853 } 848 854 855 BMessage reply; 856 bool handled = false; 849 857 switch(message->what) { 850 858 case B_GET_PROPERTY: 851 { 852 BMessage reply; 853 GetProperty(&specifier, specifier.what, property, &reply); 854 message->SendReply(&reply); 859 handled = GetProperty(&specifier, specifier.what, property, &reply); 855 860 break; 856 }857 861 858 862 case B_SET_PROPERTY: 859 { 860 BMessage reply; 861 SetProperty(&specifier, specifier.what, property, &reply); 862 message->SendReply(&reply); 863 handled = SetProperty(&specifier, specifier.what, property, &reply); 863 864 break; 864 }865 865 866 866 case B_COUNT_PROPERTIES: 867 { 868 BMessage reply; 869 CountProperties(&specifier, specifier.what, property, &reply); 870 message->SendReply(&reply); 867 handled = CountProperties(&specifier, specifier.what, property, &reply); 871 868 break; 872 }873 869 874 870 default: 875 871 break; 876 872 } 877 873 if (handled) 874 message->SendReply(&reply); 875 else 876 BView::MessageReceived(message); 878 877 break; 879 878 } … … 1133 1132 BTextView::Text() const 1134 1133 { 1135 return fText-> Text();1134 return fText->RealText(); 1136 1135 } 1137 1136 … … 1165 1164 return '\0'; 1166 1165 1167 return (*fText)[offset];1166 return fText->RealCharAt(offset); 1168 1167 } 1169 1168 … … 1636 1635 1637 1636 // special case: go down one line if inOffset is a newline 1638 if (inOffset == textLength && (*fText)[inOffset - 1]== B_ENTER) {1637 if (inOffset == textLength && fText->RealCharAt(inOffset - 1) == B_ENTER) { 1639 1638 result.y += height; 1640 1639 height = LineHeight(CountLines() - 1); … … 1863 1862 float height = (*fLines)[endLine + 1]->origin - (*fLines)[startLine]->origin; 1864 1863 1865 if (startLine != endLine && endLine == numLines - 1 && (*fText)[fText->Length() - 1]== B_ENTER)1864 if (startLine != endLine && endLine == numLines - 1 && fText->RealCharAt(fText->Length() - 1) == B_ENTER) 1866 1865 height += (*fLines)[endLine + 1]->origin - (*fLines)[endLine]->origin; 1867 1866 … … 2653 2652 2654 2653 // add the text 2655 drag->AddData("text/plain", B_MIME_TYPE, fText-> Text() + fSelStart,2654 drag->AddData("text/plain", B_MIME_TYPE, fText->RealText() + fSelStart, 2656 2655 fSelEnd - fSelStart); 2657 2656 … … 3288 3287 } 3289 3288 for ( ; (offset + delta) < limit; delta++) { 3290 uchar theChar = (*fText)[offset + delta];3289 uchar theChar = fText->RealCharAt(offset + delta); 3291 3290 if (!CanEndLine(offset + delta)) 3292 3291 break; … … 3321 3320 else { 3322 3321 int32 tabCount = 0; 3323 for (int32 i = delta - 1; (*fText)[offset + i]== B_TAB; i--)3322 for (int32 i = delta - 1; fText->RealCharAt(offset + i) == B_TAB; i--) 3324 3323 tabCount++; 3325 3324 … … 3351 3350 if (!foundNewline) { 3352 3351 for ( ; (offset + delta) < limit; delta++) { 3353 if ((*fText)[offset + delta] != B_SPACE && 3354 (*fText)[offset + delta] != B_TAB) 3352 const char realChar = fText->RealCharAt(offset + delta); 3353 if (realChar != B_SPACE 3354 && realChar != B_TAB) 3355 3355 break; 3356 3356 } 3357 if ( (offset + delta) < limit &&3358 (*fText)[offset + delta]== B_ENTER )3357 if ((offset + delta) < limit 3358 && fText->RealCharAt(offset + delta) == B_ENTER ) 3359 3359 delta++; 3360 3360 } … … 3427 3427 } else 3428 3428 #endif 3429 result += font->StringWidth(fText-> Text() + fromOffset, numChars);3429 result += font->StringWidth(fText->RealText() + fromOffset, numChars); 3430 3430 3431 3431 fromOffset += numChars; … … 3594 3594 3595 3595 int32 returnedBytes = tabChars; 3596 view->DrawString(fText->GetString(offset, &returnedBytes), returnedBytes); 3597 3596 const char *stringToDraw = fText->GetString(offset, &returnedBytes); 3597 3598 view->DrawString(stringToDraw, returnedBytes); 3598 3599 if (foundTab) { 3599 3600 float penPos = PenLocation().x - fTextRect.left; … … 4309 4310 4310 4311 } else if (strcmp(property, "Text") == 0) { 4312 4313 if (IsTypingHidden()) { 4314 // Do not allow stealing passwords via scripting 4315 beep(); 4316 return false; 4317 } 4318 4311 4319 int32 index, range; 4312 4320 -
haiku/trunk/src/kits/interface/textview_support/TextGapBuffer.cpp
r18987 r22129 8 8 */ 9 9 10 #include <cstdio> 10 11 #include <cstdlib> 11 12 #include <cstring> … … 194 195 195 196 for (long i = 0; i < numBytes; i++) 196 fScratchBuffer[i] = (*this)[fromOffset + i];197 fScratchBuffer[i] = RealCharAt(fromOffset + i); 197 198 198 199 result = fScratchBuffer; … … 204 205 uint32 numChars = UTF8CountChars(result, numBytes); 205 206 uint32 charLen = UTF8CountBytes(B_UTF8_BULLET, 1); 206 uint32 newSize = numChars * charLen + 1; 207 uint32 newSize = numChars * charLen; 208 207 209 if ((uint32)fScratchSize < newSize) { 208 210 fScratchBuffer = (char *)realloc(fScratchBuffer, newSize); … … 216 218 scratchPtr += charLen; 217 219 } 218 scratchPtr = '\0';219 220 *_numBytes = newSize - 1; 220 221 } … … 229 230 long numChars = *ioDelta; 230 231 for (long i = 0; i < numChars; i++) { 231 if (( (*this)[fromIndex + i]& 0xc0) == 0x80)232 if ((RealCharAt(fromIndex + i) & 0xc0) == 0x80) 232 233 continue; 233 if ( (*this)[fromIndex + i]== inChar) {234 if (RealCharAt(fromIndex + i) == inChar) { 234 235 *ioDelta = i; 235 236 return true; … … 244 245 _BTextGapBuffer_::Text() 245 246 { 247 const char *realText = RealText(); 248 249 if (fPasswordMode) { 250 const uint32 numChars = UTF8CountChars(realText, Length()); 251 const uint32 bulletCharLen = UTF8CountBytes(B_UTF8_BULLET, 1); 252 uint32 newSize = numChars * bulletCharLen + 1; 253 254 if ((uint32)fScratchSize < newSize) { 255 fScratchBuffer = (char *)realloc(fScratchBuffer, newSize); 256 fScratchSize = newSize; 257 } 258 259 char *scratchPtr = fScratchBuffer; 260 for (uint32 i = 0; i < numChars; i++) { 261 memcpy(scratchPtr, B_UTF8_BULLET, bulletCharLen); 262 scratchPtr += bulletCharLen; 263 } 264 scratchPtr = '\0'; 265 266 return fScratchBuffer; 267 } 268 269 return realText; 270 } 271 272 273 const char * 274 _BTextGapBuffer_::RealText() 275 { 246 276 MoveGapTo(fItemCount); 247 277 fBuffer[fItemCount] = '\0'; … … 249 279 return fBuffer; 250 280 } 251 252 253 /*char *254 _BTextGapBuffer_::RealText()255 {256 return fText;257 }*/258 281 259 282 … … 299 322 300 323 301 char302 _BTextGapBuffer_::RealCharAt(int32 offset) const303 {304 return (offset < fGapIndex) ? fBuffer[offset] : fBuffer[offset + fGapCount];305 }306 307 308 324 bool 309 325 _BTextGapBuffer_::PasswordMode() const -
haiku/trunk/src/kits/interface/textview_support/TextGapBuffer.h
r18987 r22129 30 30 31 31 const char *Text(); 32 const char *RealText(); 32 33 int32 Length() const; 33 char operator[](int32 index) const;34 35 34 36 // char *RealText();37 35 const char *GetString(int32 fromOffset, int32 *numBytes); 38 36 void GetString(int32 offset, int32 length, char *buffer); … … 66 64 67 65 inline char 68 _BTextGapBuffer_:: operator[](long index) const66 _BTextGapBuffer_::RealCharAt(long index) const 69 67 { 70 68 return (index < fGapIndex) ? fBuffer[index] : fBuffer[index + fGapCount];
