| 747 | // 3) Break after whole character |
| 748 | |
| 749 | int Document::SafeSegment(const char *text, int length, int lengthSegment) { |
| 750 | if (length <= lengthSegment) |
| 751 | return length; |
| 752 | int lastSpaceBreak = -1; |
| 753 | int lastPunctuationBreak = -1; |
| 754 | int lastEncodingAllowedBreak = -1; |
| 755 | for (int j=0; j < lengthSegment;) { |
| 756 | unsigned char ch = static_cast<unsigned char>(text[j]); |
| 757 | if (j > 0) { |
| 758 | if (IsSpaceOrTab(text[j - 1]) && !IsSpaceOrTab(text[j])) { |
| 759 | lastSpaceBreak = j; |
| 760 | } |
| 761 | if (ch < 'A') { |
| 762 | lastPunctuationBreak = j; |
| 763 | } |
| 764 | } |
| 765 | lastEncodingAllowedBreak = j; |
| 766 | |
| 767 | if (dbcsCodePage == SC_CP_UTF8) { |
| 768 | j += UTF8BytesOfLead[ch]; |
| 769 | } else if (dbcsCodePage) { |
| 770 | j += IsDBCSLeadByte(ch) ? 2 : 1; |
| 771 | } else { |
| 772 | j++; |
| 773 | } |
| 774 | } |
| 775 | if (lastSpaceBreak >= 0) { |
| 776 | return lastSpaceBreak; |
| 777 | } else if (lastPunctuationBreak >= 0) { |
| 778 | return lastPunctuationBreak; |
| 779 | } |
| 780 | return lastEncodingAllowedBreak; |
| 781 | } |
| 782 | |
| 783 | void Document::ModifiedAt(int pos) { |
| 784 | if (endStyled > pos) |
no test coverage detected