28 skipped lines |
29 | | 29 | | #include "Document.h" |
|
30 | | 30 | | #include "Editor.h" |
|
|
| | 32 | | /* |
| | 33 | | return whether this modification represents an operation that |
| | 34 | | may reasonably be deferred (not done now OR [possibly] at all) |
| | 35 | | */ |
| | 36 | | static bool CanDeferToLastStep(const DocModification& mh) { |
21 skipped lines |
| | 58 | | && (mh.modificationType & SC_MULTISTEPUNDOREDO) != 0 |
| | 59 | | && (mh.modificationType & SC_LASTSTEPINUNDOREDO) != 0 |
| | 60 | | && (mh.modificationType & SC_MULTILINEUNDOREDO) != 0; |
| | 61 | | } |
| | 62 | | |
|
33 | | 64 | | active(false), on(false), period(500) {} |
|
|
19 skipped lines |
|
|
|
| | 88 | | styleBitsSet(0), |
|
|
|
97 skipped lines |
|
158 | | 190 | | LineLayoutCache::LineLayoutCache() : |
|
159 | | 191 | | level(0), length(0), size(0), cache(0), |
|
160 | | allInvalidated(false), styleClock(-1) { | | 192 | | allInvalidated(false), styleClock(-1), useCount(0) { |
|
|
|
2 skipped lines |
|
|
168 | | 200 | | void LineLayoutCache::Allocate(int length_) { |
|
| | 201 | | PLATFORM_ASSERT(cache == NULL); |
169 | | 202 | | allInvalidated = false; |
|
170 | | 203 | | length = length_; |
|
|
8 skipped lines |
|
|
182 | | 215 | | void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) { |
|
| | 216 | | PLATFORM_ASSERT(useCount == 0); |
183 | | 217 | | int lengthForLevel = 0; |
|
184 | | 218 | | if (level == llcCaret) { |
|
185 | | 219 | | lengthForLevel = 1; |
|
4 skipped lines |
|
191 | | 225 | | if (lengthForLevel > size) { |
|
|
193 | | } else if (lengthForLevel < length) { | | |
194 | | for (int i = lengthForLevel; i < length; i++) { | | |
195 | | delete cache[i]; | | |
196 | | cache[i] = 0; | | |
197 | | } | | |
198 | | } | | |
199 | | if (!cache) { | | |
200 | | 227 | | Allocate(lengthForLevel); |
|
| | 228 | | } else { |
| | 229 | | if (lengthForLevel < length) { |
| | 230 | | for (int i = lengthForLevel; i < length; i++) { |
| | 231 | | delete cache[i]; |
| | 232 | | cache[i] = 0; |
| | 233 | | } |
| | 234 | | } |
| | 235 | | length = lengthForLevel; |
|
| | 237 | | PLATFORM_ASSERT(length == lengthForLevel); |
| | 238 | | PLATFORM_ASSERT(cache != NULL || length == 0); |
|
|
204 | | 241 | | void LineLayoutCache::Deallocate() { |
|
| | 242 | | PLATFORM_ASSERT(useCount == 0); |
205 | | 243 | | for (int i = 0; i < length; i++) |
|
|
|
|
|
| | 248 | | size = 0; |
|
|
212 | | 251 | | void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) { |
|
31 skipped lines |
|
245 | | 284 | | } else if (level == llcPage) { |
|
246 | | 285 | | if (lineNumber == lineCaret) { |
|
247 | | pos = length; | | 286 | | pos = 0; |
|
249 | | pos = lineNumber % length; | | 288 | | pos = 1 + (lineNumber % (length - 1)); |
|
251 | | 290 | | } else if (level == llcDocument) { |
|
252 | | 291 | | pos = lineNumber; |
|
|
|
| | 294 | | PLATFORM_ASSERT(useCount == 0); |
255 | | 295 | | if (cache && (pos < length)) { |
|
256 | | 296 | | if (cache[pos]) { |
|
257 | | 297 | | if ((cache[pos]->lineNumber != lineNumber) || |
|
9 skipped lines |
267 | | 307 | | cache[pos]->lineNumber = lineNumber; |
|
268 | | 308 | | cache[pos]->inCache = true; |
|
269 | | 309 | | ret = cache[pos]; |
|
| | 310 | | useCount++; |
|
|
|
11 skipped lines |
|
285 | | 326 | | if (!ll->inCache) { |
|
|
287 | | } | | 328 | | } else { |
| | 329 | | useCount--; |
| | 330 | | } |
|
|
|
53 skipped lines |
344 | | 387 | | scrollWidth = 2000; |
|
345 | | 388 | | verticalScrollBarVisible = true; |
|
346 | | 389 | | endAtLastLine = true; |
|
| | 390 | | caretSticky = false; |
|
348 | | 392 | | pixmapLine = Surface::Allocate(); |
|
349 | | 393 | | pixmapSelMargin = Surface::Allocate(); |
|
11 skipped lines |
|
|
|
364 | | lengthForEncode = 0; | | 408 | | lengthForEncode = -1; |
|
366 | | 410 | | needUpdateUI = true; |
|
367 | | 411 | | braces[0] = invalidPosition; |
|
24 skipped lines |
392 | | 436 | | wrapVisualStartIndent = 0; |
|
393 | | 437 | | actualWrapVisualStartIndent = 0; |
|
|
| | 439 | | convertPastes = true; |
| | 440 | | |
|
|
|
22 skipped lines |
420 | | 466 | | pixmapSelMargin->Release(); |
|
421 | | 467 | | pixmapSelPattern->Release(); |
|
422 | | 468 | | pixmapIndentGuide->Release(); |
|
| | 469 | | pixmapIndentGuideHighlight->Release(); |
|
|
425 | | 472 | | void Editor::InvalidateStyleData() { |
|
416 skipped lines |
842 | | 889 | | //wMain.InvalidateAll(); |
|
|
|
845 | | void Editor::RedrawSelMargin() { | | 892 | | void Editor::RedrawSelMargin(int line) { |
846 | | 893 | | if (!AbandonPaint()) { |
|
847 | | 894 | | if (vs.maskInLine) { |
|
|
|
850 | | 897 | | PRectangle rcSelMargin = GetClientRectangle(); |
|
851 | | 898 | | rcSelMargin.right = vs.fixedColumnWidth; |
|
| | 899 | | if (line != -1) { |
| | 900 | | int position = pdoc->LineStart(line); |
| | 901 | | PRectangle rcLine = RectangleFromRange(position, position); |
| | 902 | | rcSelMargin.top = rcLine.top; |
| | 903 | | rcSelMargin.bottom = rcLine.bottom; |
| | 904 | | } |
852 | | 905 | | wMain.InvalidateRectangle(rcSelMargin); |
|
|
|
44 skipped lines |
899 | | 952 | | return Platform::Maximum(currentPos, anchor); |
|
|
|
| | 955 | | void Editor::SetRectangularRange() { |
| | 956 | | if (selType == selRectangle) { |
| | 957 | | xStartSelect = XFromPosition(anchor); |
| | 958 | | xEndSelect = XFromPosition(currentPos); |
| | 959 | | } |
| | 960 | | } |
| | 961 | | |
902 | | 962 | | void Editor::InvalidateSelection(int currentPos_, int anchor_) { |
|
903 | | 963 | | int firstAffected = anchor; |
|
904 | | 964 | | if (firstAffected > currentPos) |
|
21 skipped lines |
926 | | 986 | | currentPos = currentPos_; |
|
927 | | 987 | | anchor = anchor_; |
|
|
929 | | if (selType == selRectangle) { | | |
930 | | xStartSelect = XFromPosition(anchor); | | 989 | | SetRectangularRange(); |
931 | | xEndSelect = XFromPosition(currentPos); | | |
932 | | } | | |
933 | | 990 | | ClaimSelection(); |
|
|
|
3 skipped lines |
939 | | 996 | | InvalidateSelection(currentPos_, currentPos_); |
|
940 | | 997 | | currentPos = currentPos_; |
|
|
942 | | if (selType == selRectangle) { | | |
943 | | xStartSelect = XFromPosition(anchor); | | 999 | | SetRectangularRange(); |
944 | | xEndSelect = XFromPosition(currentPos); | | |
945 | | } | | |
946 | | 1000 | | ClaimSelection(); |
|
|
|
116 skipped lines |
1065 | | 1119 | | SetTopLine(topLineNew); |
|
1066 | | 1120 | | ShowCaretAtCurrentPosition(); |
|
1067 | | 1121 | | // Perform redraw rather than scroll if many lines would be redrawn anyway. |
|
| | 1122 | | #ifndef UNDER_CE |
1068 | | 1123 | | if (abs(linesToMove) <= 10) { |
|
1069 | | 1124 | | ScrollText(linesToMove); |
|
|
|
|
| | 1128 | | #else |
| | 1129 | | Redraw(); |
| | 1130 | | #endif |
1073 | | 1131 | | if (moveThumb) { |
|
1074 | | 1132 | | SetVerticalScrollPos(); |
|
|
796 skipped lines |
1872 | | 1930 | | posLineEnd = posLineStart + ll->maxLineLength; |
|
|
1874 | | 1932 | | if (ll->validity == LineLayout::llCheckTextAndStyle) { |
|
1875 | | int lineLength = 0; | | 1933 | | int lineLength = posLineEnd - posLineStart; |
| | 1934 | | if (!vstyle.viewEOL) { |
1876 | | for (int cid = posLineStart; cid < posLineEnd; cid++) { | | 1935 | | int cid = posLineEnd - 1; |
1877 | | char chDoc = pdoc->CharAt(cid); | | |
1878 | | if (vstyle.viewEOL || (!IsEOLChar(chDoc))) { | | 1936 | | while ((cid > posLineStart) && IsEOLChar(pdoc->CharAt(cid))) { |
| | 1937 | | cid--; |
1879 | | lineLength++; | | 1938 | | lineLength--; |
|
|
1882 | | 1941 | | if (lineLength == ll->numCharsInLine) { |
|
1883 | | int numCharsInLine = 0; | | |
1884 | | 1942 | | // See if chars, styles, indicators, are all the same |
|
1885 | | 1943 | | bool allSame = true; |
|
1886 | | 1944 | | const int styleMask = pdoc->stylingBitsMask; |
|
1887 | | 1945 | | // Check base line layout |
|
| | 1946 | | char styleByte = 0; |
| | 1947 | | int numCharsInLine = 0; |
| | 1948 | | while (numCharsInLine < lineLength) { |
1888 | | for (int charInDoc = posLineStart; allSame && (charInDoc < posLineEnd); charInDoc++) { | | 1949 | | int charInDoc = numCharsInLine + posLineStart; |
1889 | | 1950 | | char chDoc = pdoc->CharAt(charInDoc); |
|
1890 | | if (vstyle.viewEOL || (!IsEOLChar(chDoc))) { | | 1951 | | styleByte = pdoc->StyleAt(charInDoc); |
| | 1952 | | allSame = allSame && |
| | 1953 | | (ll->styles[numCharsInLine] == static_cast<unsigned char>(styleByte & styleMask)); |
| | 1954 | | allSame = allSame && |
1891 | | char styleByte = pdoc->StyleAt(charInDoc); | | 1955 | | (ll->indicators[numCharsInLine] == static_cast<char>(styleByte & ~styleMask)); |
| | 1956 | | if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseMixed) |
1892 | | 1957 | | allSame = allSame && |
|
1893 | | (ll->styles[numCharsInLine] == static_cast<char>(styleByte & styleMask)); | | 1958 | | (ll->chars[numCharsInLine] == chDoc); |
| | 1959 | | else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower) |
1894 | | 1960 | | allSame = allSame && |
|
1895 | | (ll->indicators[numCharsInLine] == static_cast<char>(styleByte & ~styleMask)); | | |
1896 | | if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseUpper) | | |
1897 | | allSame = allSame && | | |
1898 | | (ll->chars[numCharsInLine] == static_cast<char>(toupper(chDoc))); | | 1961 | | (ll->chars[numCharsInLine] == static_cast<char>(tolower(chDoc))); |
1899 | | else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower) | | 1962 | | else// Style::caseUpper |
1900 | | allSame = allSame && | | 1963 | | allSame = allSame && |
1901 | | (ll->chars[numCharsInLine] == static_cast<char>(tolower(chDoc))); | | 1964 | | (ll->chars[numCharsInLine] == static_cast<char>(toupper(chDoc))); |
1902 | | else | | |
1903 | | allSame = allSame && | | |
1904 | | (ll->chars[numCharsInLine] == chDoc); | | |
1905 | | numCharsInLine++; | | 1965 | | numCharsInLine++; |
1906 | | } | | |
|
| | 1967 | | allSame = allSame && (ll->styles[numCharsInLine] == styleByte); // For eolFilled |
|
1909 | | 1969 | | ll->validity = LineLayout::llPositions; |
|
|
18 skipped lines |
|
1930 | | 1990 | | char styleByte = 0; |
|
1931 | | 1991 | | int styleMask = pdoc->stylingBitsMask; |
|
| | 1992 | | ll->styleBitsSet = 0; |
1932 | | 1993 | | // Fill base line layout |
|
1933 | | 1994 | | for (int charInDoc = posLineStart; charInDoc < posLineEnd; charInDoc++) { |
|
1934 | | 1995 | | char chDoc = pdoc->CharAt(charInDoc); |
|
1935 | | 1996 | | styleByte = pdoc->StyleAt(charInDoc); |
|
| | 1997 | | ll->styleBitsSet |= styleByte; |
1936 | | 1998 | | if (vstyle.viewEOL || (!IsEOLChar(chDoc))) { |
|
1937 | | 1999 | | ll->chars[numCharsInLine] = chDoc; |
|
1938 | | 2000 | | ll->styles[numCharsInLine] = static_cast<char>(styleByte & styleMask); |
|
20 skipped lines |
1959 | | 2021 | | bool lastSegItalics = false; |
|
1960 | | 2022 | | Font &ctrlCharsFont = vstyle.styles[STYLE_CONTROLCHAR].font; |
|
|
| | 2024 | | int ctrlCharWidth[32] = {0}; |
1962 | | 2025 | | bool isControlNext = IsControlCharacter(ll->chars[0]); |
|
1963 | | 2026 | | for (int charInLine = 0; charInLine < numCharsInLine; charInLine++) { |
|
1964 | | 2027 | | bool isControl = isControlNext; |
|
7 skipped lines |
1972 | | 2035 | | ll->positions[charInLine + 1] = ((((startsegx + 2) / |
|
1973 | | 2036 | | tabWidth) + 1) * tabWidth) - startsegx; |
|
1974 | | 2037 | | } else if (controlCharSymbol < 32) { |
|
| | 2038 | | if (ctrlCharWidth[ll->chars[charInLine]] == 0) { |
1975 | | const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]); | | 2039 | | const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]); |
1976 | | // +3 For a blank on front and rounded edge each side: | | 2040 | | // +3 For a blank on front and rounded edge each side: |
| | 2041 | | ctrlCharWidth[ll->chars[charInLine]] = |
1977 | | ll->positions[charInLine + 1] = surface->WidthText(ctrlCharsFont, ctrlChar, istrlen(ctrlChar)) + 3; | | 2042 | | surface->WidthText(ctrlCharsFont, ctrlChar, istrlen(ctrlChar)) + 3; |
| | 2043 | | } |
| | 2044 | | ll->positions[charInLine + 1] = ctrlCharWidth[ll->chars[charInLine]]; |
|
1979 | | 2046 | | char cc[2] = { static_cast<char>(controlCharSymbol), '\0' }; |
|
1980 | | 2047 | | surface->MeasureWidths(ctrlCharsFont, cc, 1, |
|
78 skipped lines |
|
|
|
| | 2129 | | if (wrapState == eWrapChar){ |
| | 2130 | | lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1) |
| | 2131 | | - posLineStart; |
| | 2132 | | p = pdoc->MovePositionOutsideChar(p + 1 + posLineStart, 1) - posLineStart; |
| | 2133 | | continue; |
2062 | | if (ll->styles[p] != ll->styles[p - 1]) { | | 2134 | | } else if (ll->styles[p] != ll->styles[p - 1]) { |
2063 | | 2135 | | lastGoodBreak = p; |
|
2064 | | 2136 | | } else if (IsSpaceOrTab(ll->chars[p - 1]) && !IsSpaceOrTab(ll->chars[p])) { |
|
2065 | | 2137 | | lastGoodBreak = p; |
|
292 skipped lines |
|
|
|
| | 2433 | | } else if (rcSegment.left > rcLine.right) { |
| | 2434 | | break; |
|
2362 | | 2436 | | startseg = i + 1; |
|
|
156 skipped lines |
2520 | | 2594 | | rcUL.bottom = rcUL.top + 1; |
|
2521 | | 2595 | | surface->FillRectangle(rcUL, textFore); |
|
|
| | 2597 | | } else if (rcSegment.left > rcLine.right) { |
| | 2598 | | break; |
|
2524 | | 2600 | | startseg = i + 1; |
|
|
|
|
2528 | | 2604 | | // Draw indicators |
|
2529 | | int indStart[INDIC_MAX + 1] = {0}; | | 2605 | | // foreach indicator... |
2530 | | for (int indica = 0; indica <= INDIC_MAX; indica++) | | |
2531 | | indStart[indica] = 0; | | |
2532 | | | | |
2533 | | for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) { | | 2606 | | for (int indicnum = 0, mask = 1 << pdoc->stylingBits; mask < 0x100; indicnum++) { |
2534 | | if ((indicPos == lineStart) || (indicPos == lineEnd) || | | 2607 | | if (!(mask & ll->styleBitsSet)) { |
2535 | | (ll->indicators[indicPos] != ll->indicators[indicPos + 1])) { | | 2608 | | mask <<= 1; |
| | 2609 | | continue; |
| | 2610 | | } |
2536 | | int mask = 1 << pdoc->stylingBits; | | 2611 | | int startPos = -1; |
| | 2612 | | // foreach style pos in line... |
2537 | | for (int indicnum = 0; mask < 0x100; indicnum++) { | | 2613 | | for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) { |
| | 2614 | | // look for starts... |
2538 | | if ((indicPos == lineStart) || (indicPos == lineEnd)) { | | 2615 | | if (startPos < 0) { |
2539 | | indStart[indicnum] = ll->positions[indicPos]; | | 2616 | | // NOT in indicator run, looking for START |
2540 | | } else if ((ll->indicators[indicPos + 1] & mask) && !(ll->indicators[indicPos] & mask)) { | | 2617 | | if (indicPos < lineEnd && (ll->indicators[indicPos] & mask)) |
2541 | | indStart[indicnum] = ll->positions[indicPos + 1]; | | 2618 | | startPos = indicPos; |
2542 | | } | | 2619 | | } |
| | 2620 | | // ... or ends |
2543 | | if ((ll->indicators[indicPos] & mask) && | | 2621 | | if (startPos >= 0) { |
| | 2622 | | // IN indicator run, looking for END |
2544 | | ((indicPos == lineEnd) || !(ll->indicators[indicPos + 1] & mask))) { | | 2623 | | if (indicPos >= lineEnd || !(ll->indicators[indicPos] & mask)) { |
2545 | | int endIndicator = indicPos; | | 2624 | | // AT end of indicator run, DRAW it! |
2546 | | if (endIndicator >= lineEnd) | | |
2547 | | endIndicator = lineEnd-1; | | |
2548 | | 2625 | | PRectangle rcIndic( |
|
2549 | | indStart[indicnum] + xStart - subLineStart, | | 2626 | | ll->positions[startPos] + xStart - subLineStart, |
2550 | | 2627 | | rcLine.top + vsDraw.maxAscent, |
|
2551 | | ll->positions[endIndicator + 1] + xStart - subLineStart, | | 2628 | | ll->positions[indicPos] + xStart - subLineStart, |
2552 | | 2629 | | rcLine.top + vsDraw.maxAscent + 3); |
|
2553 | | 2630 | | vsDraw.indicators[indicnum].Draw(surface, rcIndic, rcLine); |
|
| | 2631 | | // RESET control var |
| | 2632 | | startPos = -1; |
|
2555 | | mask = mask << 1; | | |
|
|
| | 2636 | | mask <<= 1; |
|
2559 | | 2638 | | // End of the drawing of the current line |
|
2560 | | 2639 | | if (!twoPhaseDraw) { |
|
68 skipped lines |
2629 | | 2708 | | if (bufferedDraw) { |
|
2630 | | 2709 | | if (!pixmapLine->Initialised()) { |
|
2631 | | 2710 | | PRectangle rcClient = GetClientRectangle(); |
|
2632 | | pixmapLine->InitPixMap(rcClient.Width(), rcClient.Height(), | | 2711 | | pixmapLine->InitPixMap(rcClient.Width(), vs.lineHeight, |
2633 | | 2712 | | surfaceWindow, wMain.GetID()); |
|
2634 | | 2713 | | pixmapSelMargin->InitPixMap(vs.fixedColumnWidth, |
|
2635 | | 2714 | | rcClient.Height(), surfaceWindow, wMain.GetID()); |
|
124 skipped lines |
2760 | | 2839 | | //ElapsedTime et; |
|
2761 | | 2840 | | if (lineDoc != lineDocPrevious) { |
|
|
| | 2842 | | // For rectangular selection this accesses the layout cache so should be after layout returned. |
| | 2843 | | lineIterator.SetAt(lineDoc); |
2763 | | 2844 | | ll.Set(RetrieveLineLayout(lineDoc)); |
|
2764 | | 2845 | | LayoutLine(lineDoc, surface, vs, ll, wrapWidth); |
|
2765 | | 2846 | | lineDocPrevious = lineDoc; |
|
5 skipped lines |
2771 | | 2852 | | ll->selStart = SelectionStart(); |
|
2772 | | 2853 | | ll->selEnd = SelectionEnd(); |
|
|
2774 | | lineIterator.SetAt(lineDoc); | | |
2775 | | 2855 | | ll->selStart = lineIterator.startPos; |
|
2776 | | 2856 | | ll->selEnd = lineIterator.endPos; |
|
|
142 skipped lines |
|
|
|
| | 3003 | | ll.Set(0); |
2923 | | 3004 | | //if (durPaint < 0.00000001) |
|
2924 | | 3005 | | // durPaint = 0.00000001; |
|
|
234 skipped lines |
3160 | | 3241 | | int nMax = MaxScrollPos(); |
|
3161 | | 3242 | | int nPage = LinesOnScreen(); |
|
3162 | | 3243 | | bool modified = ModifyScrollBars(nMax + nPage - 1, nPage); |
|
| | 3244 | | if (modified) { |
| | 3245 | | DwellEnd(true); |
| | 3246 | | } |
|
3164 | | 3248 | | // TODO: ensure always showing as many lines as possible |
|
3165 | | 3249 | | // May not be, if, for example, window made larger |
|
33 skipped lines |
3199 | | 3283 | | void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { |
|
3200 | | 3284 | | bool wasSelection = currentPos != anchor; |
|
3201 | | 3285 | | ClearSelection(); |
|
| | 3286 | | bool charReplaceAction = false; |
3202 | | 3287 | | if (inOverstrike && !wasSelection && !RangeContainsProtected(currentPos, currentPos + 1)) { |
|
3203 | | 3288 | | if (currentPos < (pdoc->Length())) { |
|
3204 | | 3289 | | if (!IsEOLChar(pdoc->CharAt(currentPos))) { |
|
| | 3290 | | charReplaceAction = true; |
| | 3291 | | pdoc->BeginUndoAction(); |
3205 | | 3292 | | pdoc->DelChar(currentPos); |
|
|
|
1 skipped line |
3209 | | 3296 | | if (pdoc->InsertString(currentPos, s, len)) { |
|
3210 | | 3297 | | SetEmptySelection(currentPos + len); |
|
|
| | 3299 | | if (charReplaceAction) { |
| | 3300 | | pdoc->EndUndoAction(); |
| | 3301 | | } |
3212 | | 3302 | | EnsureCaretVisible(); |
|
3213 | | 3303 | | // Avoid blinking during rapid typing: |
|
3214 | | 3304 | | ShowCaretAtCurrentPosition(); |
|
| | 3305 | | if (!caretSticky) { |
3215 | | SetLastXChosen(); | | 3306 | | SetLastXChosen(); |
| | 3307 | | } |
|
3217 | | 3309 | | if (treatAsDBCS) { |
|
3218 | | 3310 | | NotifyChar((static_cast<unsigned char>(s[0]) << 8) | |
|
73 skipped lines |
3292 | | 3384 | | currentPos = 0; |
|
|
3294 | | 3386 | | SetVerticalScrollPos(); |
|
3295 | | InvalidateStyleRedraw(); // RPD: patch #1106564 | | 3387 | | InvalidateStyleRedraw(); |
|
|
3298 | | 3390 | | void Editor::ClearDocumentStyle() { |
|
72 skipped lines |
3371 | | 3463 | | if (pdoc->CanUndo()) { |
|
3372 | | 3464 | | InvalidateCaret(); |
|
3373 | | 3465 | | int newPos = pdoc->Undo(); |
|
| | 3466 | | if (newPos >= 0) |
3374 | | SetEmptySelection(newPos); | | 3467 | | SetEmptySelection(newPos); |
3375 | | 3468 | | EnsureCaretVisible(); |
|
|
|
1 skipped line |
3379 | | 3472 | | void Editor::Redo() { |
|
3380 | | 3473 | | if (pdoc->CanRedo()) { |
|
3381 | | 3474 | | int newPos = pdoc->Redo(); |
|
| | 3475 | | if (newPos >= 0) |
3382 | | SetEmptySelection(newPos); | | 3476 | | SetEmptySelection(newPos); |
3383 | | 3477 | | EnsureCaretVisible(); |
|
|
|
39 skipped lines |
3425 | | 3519 | | void Editor::NotifyFocus(bool) {} |
|
|
3427 | | 3521 | | void Editor::NotifyStyleToNeeded(int endStyleNeeded) { |
|
3428 | | SCNotification scn; | | 3522 | | SCNotification scn = {0}; |
3429 | | 3523 | | scn.nmhdr.code = SCN_STYLENEEDED; |
|
3430 | | 3524 | | scn.position = endStyleNeeded; |
|
3431 | | 3525 | | NotifyParent(scn); |
|
4 skipped lines |
|
|
3438 | | 3532 | | void Editor::NotifyChar(int ch) { |
|
3439 | | SCNotification scn; | | 3533 | | SCNotification scn = {0}; |
3440 | | 3534 | | scn.nmhdr.code = SCN_CHARADDED; |
|
|
3442 | | 3536 | | NotifyParent(scn); |
|
6 skipped lines |
|
|
3451 | | 3545 | | void Editor::NotifySavePoint(bool isSavePoint) { |
|
3452 | | SCNotification scn; | | 3546 | | SCNotification scn = {0}; |
3453 | | 3547 | | if (isSavePoint) { |
|
3454 | | 3548 | | scn.nmhdr.code = SCN_SAVEPOINTREACHED; |
|
|
3 skipped lines |
|
|
3461 | | 3555 | | void Editor::NotifyModifyAttempt() { |
|
3462 | | SCNotification scn; | | 3556 | | SCNotification scn = {0}; |
3463 | | 3557 | | scn.nmhdr.code = SCN_MODIFYATTEMPTRO; |
|
3464 | | 3558 | | NotifyParent(scn); |
|
|
|
3467 | | 3561 | | void Editor::NotifyDoubleClick(Point, bool) { |
|
3468 | | SCNotification scn; | | 3562 | | SCNotification scn = {0}; |
3469 | | 3563 | | scn.nmhdr.code = SCN_DOUBLECLICK; |
|
3470 | | 3564 | | NotifyParent(scn); |
|
|
|
3473 | | 3567 | | void Editor::NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt) { |
|
3474 | | SCNotification scn; | | 3568 | | SCNotification scn = {0}; |
3475 | | 3569 | | scn.nmhdr.code = SCN_HOTSPOTDOUBLECLICK; |
|
3476 | | 3570 | | scn.position = position; |
|
3477 | | 3571 | | scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | |
|
2 skipped lines |
|
|
3482 | | 3576 | | void Editor::NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt) { |
|
3483 | | SCNotification scn; | | 3577 | | SCNotification scn = {0}; |
3484 | | 3578 | | scn.nmhdr.code = SCN_HOTSPOTCLICK; |
|
3485 | | 3579 | | scn.position = position; |
|
3486 | | 3580 | | scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | |
|
2 skipped lines |
|
|
3491 | | 3585 | | void Editor::NotifyUpdateUI() { |
|
3492 | | SCNotification scn; | | 3586 | | SCNotification scn = {0}; |
3493 | | 3587 | | scn.nmhdr.code = SCN_UPDATEUI; |
|
3494 | | 3588 | | NotifyParent(scn); |
|
|
|
3497 | | 3591 | | void Editor::NotifyPainted() { |
|
3498 | | SCNotification scn; | | 3592 | | SCNotification scn = {0}; |
3499 | | 3593 | | scn.nmhdr.code = SCN_PAINTED; |
|
3500 | | 3594 | | NotifyParent(scn); |
|
|
7 skipped lines |
3509 | | 3603 | | x += vs.ms[margin].width; |
|
|
3511 | | 3605 | | if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) { |
|
3512 | | SCNotification scn; | | 3606 | | SCNotification scn = {0}; |
3513 | | 3607 | | scn.nmhdr.code = SCN_MARGINCLICK; |
|
3514 | | 3608 | | scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | |
|
3515 | | 3609 | | (alt ? SCI_ALT : 0); |
|
7 skipped lines |
|
|
3525 | | 3619 | | void Editor::NotifyNeedShown(int pos, int len) { |
|
3526 | | SCNotification scn; | | 3620 | | SCNotification scn = {0}; |
3527 | | 3621 | | scn.nmhdr.code = SCN_NEEDSHOWN; |
|
3528 | | 3622 | | scn.position = pos; |
|
3529 | | 3623 | | scn.length = len; |
|
1 skipped line |
|
|
3533 | | 3627 | | void Editor::NotifyDwelling(Point pt, bool state) { |
|
3534 | | SCNotification scn; | | 3628 | | SCNotification scn = {0}; |
3535 | | 3629 | | scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND; |
|
3536 | | 3630 | | scn.position = PositionFromLocationClose(pt); |
|
|
2 skipped lines |
|
|
3542 | | 3636 | | void Editor::NotifyZoom() { |
|
3543 | | SCNotification scn; | | 3637 | | SCNotification scn = {0}; |
3544 | | 3638 | | scn.nmhdr.code = SCN_ZOOM; |
|
3545 | | 3639 | | NotifyParent(scn); |
|
|
5 skipped lines |
|
|
3554 | | 3648 | | void Editor::NotifyMove(int position) { |
|
3555 | | SCNotification scn; | | 3649 | | SCNotification scn = {0}; |
3556 | | 3650 | | scn.nmhdr.code = SCN_POSCHANGED; |
|
3557 | | 3651 | | scn.position = position; |
|
3558 | | 3652 | | NotifyParent(scn); |
|
5 skipped lines |
|
|
3566 | | 3660 | | void Editor::CheckModificationForWrap(DocModification mh) { |
|
3567 | | if ((mh.modificationType & SC_MOD_INSERTTEXT) || | | 3661 | | if (mh.modificationType & (SC_MOD_INSERTTEXT|SC_MOD_DELETETEXT)) { |
3568 | | (mh.modificationType & SC_MOD_DELETETEXT)) { | | |
3569 | | 3662 | | llc.Invalidate(LineLayout::llCheckTextAndStyle); |
|
3570 | | 3663 | | if (wrapState != eWrapNone) { |
|
3571 | | 3664 | | int lineDoc = pdoc->LineFromPosition(mh.position); |
|
69 skipped lines |
3641 | | 3734 | | // Some lines are hidden so may need shown. |
|
3642 | | 3735 | | // TODO: check if the modified area is hidden. |
|
3643 | | 3736 | | if (mh.modificationType & SC_MOD_BEFOREINSERT) { |
|
3644 | | NotifyNeedShown(mh.position, mh.length); | | 3737 | | NotifyNeedShown(mh.position, 0); |
3645 | | 3738 | | } else if (mh.modificationType & SC_MOD_BEFOREDELETE) { |
|
3646 | | 3739 | | NotifyNeedShown(mh.position, mh.length); |
|
|
11 skipped lines |
3659 | | 3752 | | CheckModificationForWrap(mh); |
|
3660 | | 3753 | | if (mh.linesAdded != 0) { |
|
3661 | | 3754 | | // Avoid scrolling of display if change before current display |
|
3662 | | if (mh.position < posTopLine) { | | 3755 | | if (mh.position < posTopLine && !CanDeferToLastStep(mh)) { |
3663 | | 3756 | | int newTop = Platform::Clamp(topLine + mh.linesAdded, 0, MaxScrollPos()); |
|
3664 | | 3757 | | if (newTop != topLine) { |
|
3665 | | 3758 | | SetTopLine(newTop); |
|
4 skipped lines |
3670 | | 3763 | | //Platform::DebugPrintf("** %x Doc Changed\n", this); |
|
3671 | | 3764 | | // TODO: could invalidate from mh.startModification to end of screen |
|
3672 | | 3765 | | //InvalidateRange(mh.position, mh.position + mh.length); |
|
3673 | | if (paintState == notPainting) { | | 3766 | | if (paintState == notPainting && !CanDeferToLastStep(mh)) { |
|
|
|
3677 | | 3770 | | //Platform::DebugPrintf("** %x Line Changed %d .. %d\n", this, |
|
3678 | | 3771 | | // mh.position, mh.position + mh.length); |
|
3679 | | if (paintState == notPainting) { | | 3772 | | if (paintState == notPainting && mh.length && !CanEliminate(mh)) { |
3680 | | 3773 | | InvalidateRange(mh.position, mh.position + mh.length); |
|
|
|
|
|
3685 | | if (mh.linesAdded != 0) { | | 3778 | | if (mh.linesAdded != 0 && !CanDeferToLastStep(mh)) { |
3686 | | 3779 | | SetScrollBars(); |
|
|
|
3689 | | 3782 | | if (mh.modificationType & SC_MOD_CHANGEMARKER) { |
|
3690 | | if (paintState == notPainting) { | | 3783 | | if ((paintState == notPainting) || !PaintContainsMargin()) { |
| | 3784 | | if (mh.modificationType & SC_MOD_CHANGEFOLD) { |
| | 3785 | | // Fold changes can affect the drawing of following lines so redraw whole margin |
3691 | | RedrawSelMargin(); | | 3786 | | RedrawSelMargin(); |
| | 3787 | | } else { |
| | 3788 | | RedrawSelMargin(mh.line); |
| | 3789 | | } |
|
|
|
| | 3793 | | // NOW pay the piper WRT "deferred" visual updates |
| | 3794 | | if (IsLastStep(mh)) { |
| | 3795 | | SetScrollBars(); |
| | 3796 | | Redraw(); |
| | 3797 | | } |
| | 3798 | | |
3695 | | 3799 | | // If client wants to see this modification |
|
3696 | | 3800 | | if (mh.modificationType & modEventMask) { |
|
3697 | | 3801 | | if ((mh.modificationType & SC_MOD_CHANGESTYLE) == 0) { |
|
1 skipped line |
3699 | | 3803 | | NotifyChange(); // Send EN_CHANGE |
|
|
|
3702 | | SCNotification scn; | | 3806 | | SCNotification scn = {0}; |
3703 | | 3807 | | scn.nmhdr.code = SCN_MODIFIED; |
|
3704 | | 3808 | | scn.position = mh.position; |
|
3705 | | 3809 | | scn.modificationType = mh.modificationType; |
|
11 skipped lines |
3717 | | 3821 | | /* Do nothing */ |
|
|
|
3720 | | void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long lParam) { | | 3824 | | void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { |
|
3722 | | 3826 | | // Enumerates all macroable messages |
|
3723 | | 3827 | | switch (iMessage) { |
|
94 skipped lines |
3818 | | 3922 | | case SCI_LINEENDRECTEXTEND: |
|
3819 | | 3923 | | case SCI_PAGEUPRECTEXTEND: |
|
3820 | | 3924 | | case SCI_PAGEDOWNRECTEXTEND: |
|
| | 3925 | | case SCI_SELECTIONDUPLICATE: |
|
|
3823 | | 3928 | | // Filter out all others like display changes. Also, newlines are redundant |
|
5 skipped lines |
|
|
3831 | | 3936 | | // Send notification |
|
3832 | | SCNotification scn; | | 3937 | | SCNotification scn = {0}; |
3833 | | 3938 | | scn.nmhdr.code = SCN_MACRORECORD; |
|
3834 | | 3939 | | scn.message = iMessage; |
|
3835 | | 3940 | | scn.wParam = wParam; |
|
95 skipped lines |
|
|
|
3934 | | void Editor::LineDuplicate() { | | 4039 | | void Editor::Duplicate(bool forLine) { |
| | 4040 | | int start = SelectionStart(); |
| | 4041 | | int end = SelectionEnd(); |
| | 4042 | | if (start == end) { |
| | 4043 | | forLine = true; |
| | 4044 | | } |
| | 4045 | | if (forLine) { |
3935 | | int line = pdoc->LineFromPosition(currentPos); | | 4046 | | int line = pdoc->LineFromPosition(currentPos); |
3936 | | int start = pdoc->LineStart(line); | | 4047 | | start = pdoc->LineStart(line); |
3937 | | int end = pdoc->LineEnd(line); | | 4048 | | end = pdoc->LineEnd(line); |
| | 4049 | | } |
3938 | | char *thisLine = CopyRange(start, end); | | 4050 | | char *text = CopyRange(start, end); |
| | 4051 | | if (forLine) { |
3939 | | const char *eol = StringFromEOLMode(pdoc->eolMode); | | 4052 | | const char *eol = StringFromEOLMode(pdoc->eolMode); |
3940 | | pdoc->InsertString(end, eol); | | 4053 | | pdoc->InsertString(end, eol); |
3941 | | pdoc->InsertString(end + istrlen(eol), thisLine, end - start); | | 4054 | | pdoc->InsertString(end + istrlen(eol), text, end - start); |
| | 4055 | | } else { |
| | 4056 | | pdoc->InsertString(end, text, end - start); |
| | 4057 | | } |
3942 | | delete []thisLine; | | 4058 | | delete []text; |
|
|
3945 | | 4061 | | void Editor::CancelModes() { |
|
17 skipped lines |
|
3964 | | 4080 | | SetLastXChosen(); |
|
3965 | | 4081 | | EnsureCaretVisible(); |
|
| | 4082 | | // Avoid blinking during rapid typing: |
| | 4083 | | ShowCaretAtCurrentPosition(); |
|
|
3968 | | 4086 | | void Editor::CursorUpOrDown(int direction, selTypes sel) { |
|
14 skipped lines |
3983 | | 4101 | | MovePositionTo(posNew, sel); |
|
|
|
| | 4104 | | void Editor::ParaUpOrDown(int direction, selTypes sel) { |
| | 4105 | | int lineDoc, savedPos = currentPos; |
| | 4106 | | do { |
| | 4107 | | MovePositionTo(direction > 0 ? pdoc->ParaDown(currentPos) : pdoc->ParaUp(currentPos), sel); |
| | 4108 | | lineDoc = pdoc->LineFromPosition(currentPos); |
6 skipped lines |
| | 4115 | | } |
| | 4116 | | } |
| | 4117 | | } while (!cs.GetVisible(lineDoc)); |
| | 4118 | | } |
| | 4119 | | |
3986 | | 4120 | | int Editor::StartEndDisplayLine(int pos, bool start) { |
|
3987 | | 4121 | | RefreshStyleData(); |
|
3988 | | 4122 | | int line = pdoc->LineFromPosition(pos); |
|
38 skipped lines |
4027 | | 4161 | | CursorUpOrDown(1, selRectangle); |
|
|
4029 | | 4163 | | case SCI_PARADOWN: |
|
4030 | | MovePositionTo(pdoc->ParaDown(currentPos)); | | 4164 | | ParaUpOrDown(1); |
|
4032 | | 4166 | | case SCI_PARADOWNEXTEND: |
|
4033 | | MovePositionTo(pdoc->ParaDown(currentPos), selStream); | | 4167 | | ParaUpOrDown(1, selStream); |
|
4035 | | 4169 | | case SCI_LINESCROLLDOWN: |
|
4036 | | 4170 | | ScrollTo(topLine + 1); |
|
9 skipped lines |
4046 | | 4180 | | CursorUpOrDown(-1, selRectangle); |
|
|
4048 | | 4182 | | case SCI_PARAUP: |
|
4049 | | MovePositionTo(pdoc->ParaUp(currentPos)); | | 4183 | | ParaUpOrDown(-1); |
|
4051 | | 4185 | | case SCI_PARAUPEXTEND: |
|
4052 | | MovePositionTo(pdoc->ParaUp(currentPos), selStream); | | 4186 | | ParaUpOrDown(-1, selStream); |
|
4054 | | 4188 | | case SCI_LINESCROLLUP: |
|
4055 | | 4189 | | ScrollTo(topLine - 1); |
|
183 skipped lines |
|
4240 | | 4374 | | case SCI_DELETEBACK: |
|
4241 | | 4375 | | DelCharBack(true); |
|
| | 4376 | | if (!caretSticky) { |
4242 | | SetLastXChosen(); | | 4377 | | SetLastXChosen(); |
| | 4378 | | } |
4243 | | 4379 | | EnsureCaretVisible(); |
|
|
4245 | | 4381 | | case SCI_DELETEBACKNOTLINE: |
|
4246 | | 4382 | | DelCharBack(false); |
|
| | 4383 | | if (!caretSticky) { |
4247 | | SetLastXChosen(); | | 4384 | | SetLastXChosen(); |
| | 4385 | | } |
4248 | | 4386 | | EnsureCaretVisible(); |
|
|
|
|
| | 4390 | | if (!caretSticky) { |
4252 | | SetLastXChosen(); | | 4391 | | SetLastXChosen(); |
| | 4392 | | } |
4253 | | 4393 | | EnsureCaretVisible(); |
|
|
4255 | | 4395 | | case SCI_BACKTAB: |
|
|
| | 4397 | | if (!caretSticky) { |
4257 | | SetLastXChosen(); | | 4398 | | SetLastXChosen(); |
| | 4399 | | } |
4258 | | 4400 | | EnsureCaretVisible(); |
|
|
4260 | | 4402 | | case SCI_NEWLINE: |
|
100 skipped lines |
4361 | | 4503 | | LineTranspose(); |
|
|
4363 | | 4505 | | case SCI_LINEDUPLICATE: |
|
| | 4506 | | Duplicate(true); |
| | 4507 | | break; |
| | 4508 | | case SCI_SELECTIONDUPLICATE: |
4364 | | LineDuplicate(); | | 4509 | | Duplicate(false); |
|
4366 | | 4511 | | case SCI_LOWERCASE: |
|
4367 | | 4512 | | ChangeCaseOfSelection(false); |
|
610 skipped lines |
4978 | | 5123 | | NotifyHotSpotClicked(newPos, shift, ctrl, alt); |
|
|
|
4981 | | inDragDrop = PointInSelection(pt); | | 5126 | | inDragDrop = PointInSelection(pt) && !SelectionEmpty(); |
|
4983 | | 5128 | | if (inDragDrop) { |
|
4984 | | 5129 | | SetMouseCapture(false); |
|
7 skipped lines |
4992 | | 5137 | | SetEmptySelection(newPos); |
|
|
4994 | | 5139 | | selType = alt ? selRectangle : selStream; |
|
4995 | | xStartSelect = xEndSelect = pt.x - vs.fixedColumnWidth + xOffset; | | |
4996 | | 5140 | | selectionType = selChar; |
|
4997 | | 5141 | | originalAnchorPos = currentPos; |
|
| | 5142 | | SetRectangularRange(); |
|
|
|
130 skipped lines |
|
|
5133 | | 5278 | | // Display regular (drag) cursor over selection |
|
5134 | | if (PointInSelection(pt)) { | | 5279 | | if (PointInSelection(pt) && !SelectionEmpty()) { |
5135 | | 5280 | | DisplayCursor(Window::cursorArrow); |
|
5136 | | 5281 | | } else if (PointIsHotspot(pt)) { |
|
5137 | | 5282 | | DisplayCursor(Window::cursorHand); |
|
6 skipped lines |
|
|
5146 | | 5291 | | void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { |
|
5147 | | //Platform::DebugPrintf("ButtonUp %d\n", HaveMouseCapture()); | | 5292 | | //Platform::DebugPrintf("ButtonUp %d\n", HaveMouseCapture()); |
5148 | | 5293 | | if (HaveMouseCapture()) { |
|
5149 | | 5294 | | if (PointInSelMargin(pt)) { |
|
5150 | | 5295 | | DisplayCursor(Window::cursorReverseArrow); |
|
37 skipped lines |
5188 | | 5333 | | SetSelection(newPos); |
|
|
|
5191 | | // Now we rely on the current pos to compute rectangular selection | | |
5192 | | xStartSelect = XFromPosition(anchor); | | |
5193 | | xEndSelect = XFromPosition(currentPos); | | 5336 | | SetRectangularRange(); |
5194 | | 5337 | | lastClickTime = curTime; |
|
5195 | | 5338 | | lastClick = pt; |
|
5196 | | 5339 | | lastXChosen = pt.x; |
|
17 skipped lines |
5214 | | 5357 | | if (timer.ticksToWait <= 0) { |
|
5215 | | 5358 | | caret.on = !caret.on; |
|
5216 | | 5359 | | timer.ticksToWait = caret.period; |
|
| | 5360 | | if (caret.active) { |
5217 | | InvalidateCaret(); | | 5361 | | InvalidateCaret(); |
| | 5362 | | } |
|
|
5220 | | 5365 | | if ((dwellDelay < SC_TIME_FOREVER) && |
|
42 skipped lines |
|
|
|
5266 | | static bool IsIn(int a, int minimum, int maximum) { | | 5411 | | bool Editor::PaintContains(PRectangle rc) { |
5267 | | return (a >= minimum) && (a <= maximum); | | 5412 | | return rcPaint.Contains(rc); |
|
|
5270 | | static bool IsOverlap(int mina, int maxa, int minb, int maxb) { | | 5415 | | bool Editor::PaintContainsMargin() { |
5271 | | return | | 5416 | | PRectangle rcSelMargin = GetClientRectangle(); |
5272 | | IsIn(mina, minb, maxb) || | | 5417 | | rcSelMargin.right = vs.fixedColumnWidth; |
5273 | | IsIn(maxa, minb, maxb) || | | |
5274 | | IsIn(minb, mina, maxa) || | | |
5275 | | IsIn(maxb, mina, maxa); | | 5418 | | return PaintContains(rcSelMargin); |
|
|
5278 | | 5421 | | void Editor::CheckForChangeOutsidePaint(Range r) { |
|
2 skipped lines |
5281 | | 5424 | | if (!r.Valid()) |
|
|
|
| | 5427 | | PRectangle rcRange = RectangleFromRange(r.start, r.end); |
5284 | | 5428 | | PRectangle rcText = GetTextRectangle(); |
|
5285 | | // Determine number of lines displayed including a possible partially displayed last line | | |
5286 | | int linesDisplayed = (rcText.bottom - rcText.top - 1) / vs.lineHeight + 1; | | 5429 | | if (rcRange.top < rcText.top) { |
5287 | | int bottomLine = topLine + linesDisplayed - 1; | | |
5288 | | | | |
5289 | | int lineRangeStart = cs.DisplayFromDoc(pdoc->LineFromPosition(r.start)); | | |
5290 | | int lineRangeEnd = cs.DisplayFromDoc(pdoc->LineFromPosition(r.end)); | | |
5291 | | if (!IsOverlap(topLine, bottomLine, lineRangeStart, lineRangeEnd)) { | | |
5292 | | //Platform::DebugPrintf("No overlap (%d-%d) with window(%d-%d)\n", | | |
5293 | | // lineRangeStart, lineRangeEnd, topLine, bottomLine); | | |
5294 | | return; | | 5430 | | rcRange.top = rcText.top; |
|
5296 | | | | |
5297 | | // Assert rcPaint contained within or equal to rcText | | |
5298 | | if (rcPaint.top > rcText.top) { | | 5432 | | if (rcRange.bottom > rcText.bottom) { |
5299 | | // does range intersect rcText.top .. rcPaint.top | | |
5300 | | int paintTopLine = ((rcPaint.top - rcText.top - 1) / vs.lineHeight) + topLine; | | 5433 | | rcRange.bottom = rcText.bottom; |
5301 | | // paintTopLine is the top line of the paint rectangle or the line just above if that line is completely inside the paint rectangle | | |
5302 | | if (IsOverlap(topLine, paintTopLine, lineRangeStart, lineRangeEnd)) { | | |
5303 | | //Platform::DebugPrintf("Change (%d-%d) in top npv(%d-%d)\n", | | |
5304 | | // lineRangeStart, lineRangeEnd, topLine, paintTopLine); | | |
5305 | | AbandonPaint(); | | |
5306 | | return; | | |
5307 | | } | | |
|
5309 | | if (rcPaint.bottom < rcText.bottom) { | | |
5310 | | // does range intersect rcPaint.bottom .. rcText.bottom | | |
5311 | | int paintBottomLine = ((rcPaint.bottom - rcText.top - 1) / vs.lineHeight + 1) + topLine; | | |
5312 | | // paintTopLine is the bottom line of the paint rectangle or the line just below if that line is completely inside the paint rectangle | | |
5313 | | if (IsOverlap(paintBottomLine, bottomLine, lineRangeStart, lineRangeEnd)) { | | |
26 skipped lines |
5340 | | return '<'; | | |
5341 | | default: | | |
5342 | | return '\0'; | | |
5343 | | } | | |
5344 | | } | | |
|
5346 | | // TODO: should be able to extend styled region to find matching brace | | |
5347 | | // TODO: may need to make DBCS safe | | |
5348 | | // so should be moved into Document | | |
5349 | | int Editor::BraceMatch(int position, int /*maxReStyle*/) { | | |
5350 | | char chBrace = pdoc->CharAt(position); | | |
5351 | | char chSeek = BraceOpposite(chBrace); | | |
5352 | | if (chSeek == '\0') | | |
5353 | | return - 1; | | |
5354 | | char styBrace = static_cast<char>( | | |
5355 | | pdoc->StyleAt(position) & pdoc->stylingBitsMask); | | |
5356 | | int direction = -1; | | |
5357 | | if (chBrace == '(' || chBrace == '[' || chBrace == '{' || chBrace == '<') | | |
5358 | | direction = 1; | | |
5359 | | int depth = 1; | | |
5360 | | position = position + direction; | | |
5361 | | while ((position >= 0) && (position < pdoc->Length())) { | | |
5362 | | char chAtPos = pdoc->CharAt(position); | | |
5363 | | char styAtPos = static_cast<char>(pdoc->StyleAt(position) & pdoc->stylingBitsMask); | | |
5364 | | if ((position > pdoc->GetEndStyled()) || (styAtPos == styBrace)) { | | 5436 | | if (!PaintContains(rcRange)) { |
5365 | | if (chAtPos == chBrace) | | |
5366 | | depth++; | | |
5367 | | if (chAtPos == chSeek) | | |
5368 | | depth--; | | |
5369 | | if (depth == 0) | | |
5370 | | return position; | | 5437 | | AbandonPaint(); |
|
5372 | | position = position + direction; | | |
|
5374 | | return - 1; | | |
|
|
5377 | | 5442 | | void Editor::SetBraceHighlight(Position pos0, Position pos1, int matchStyle) { |
|
43 skipped lines |
5421 | | 5486 | | NeedWrapping(); |
|
|
5423 | | 5488 | | pdoc->AddWatcher(this, 0); |
|
5424 | | Redraw(); | | |
5425 | | 5489 | | SetScrollBars(); |
|
| | 5490 | | Redraw(); |
|
|
|
129 skipped lines |
|
|
|
| | 5626 | | int Editor::WrapCount(int line) { |
| | 5627 | | AutoSurface surface(this); |
| | 5628 | | AutoLineLayout ll(llc, RetrieveLineLayout(line)); |
| | 5629 | | |
| | 5630 | | if (surface && ll) { |
2 skipped lines |
| | 5633 | | } else { |
| | 5634 | | return 1; |
| | 5635 | | } |
| | 5636 | | } |
| | 5637 | | |
5561 | | 5638 | | static bool ValidMargin(unsigned long wParam) { |
|
5562 | | 5639 | | return wParam < ViewStyle::margins; |
|
|
57 skipped lines |
|
5622 | | 5699 | | case SCI_PASTE: |
|
|
| | 5701 | | if (!caretSticky) { |
5624 | | SetLastXChosen(); | | 5702 | | SetLastXChosen(); |
| | 5703 | | } |
5625 | | 5704 | | EnsureCaretVisible(); |
|
|
|
9 skipped lines |
|
|
5639 | | 5718 | | case SCI_CANUNDO: |
|
5640 | | return pdoc->CanUndo() ? 1 : 0; | | 5719 | | return (pdoc->CanUndo() && !pdoc->IsReadOnly()) ? 1 : 0; |
|
5642 | | 5721 | | case SCI_EMPTYUNDOBUFFER: |
|
5643 | | 5722 | | pdoc->DeleteUndoHistory(); |
|
422 skipped lines |
|
|
6068 | | 6147 | | case SCI_CANREDO: |
|
6069 | | return pdoc->CanRedo() ? 1 : 0; | | 6148 | | return (pdoc->CanRedo() && !pdoc->IsReadOnly()) ? 1 : 0; |
|
6071 | | 6150 | | case SCI_MARKERLINEFROMHANDLE: |
|
6072 | | 6151 | | return pdoc->LineFromHandle(wParam); |
|
33 skipped lines |
6106 | | 6185 | | if (lParam == 0) { |
|
6107 | | 6186 | | return 1 + lineEnd - lineStart; |
|
|
| | 6188 | | PLATFORM_ASSERT(wParam > 0); |
6109 | | 6189 | | char *ptr = CharPtrFromSPtr(lParam); |
|
6110 | | 6190 | | unsigned int iPlace = 0; |
|
6111 | | 6191 | | for (unsigned int iChar = lineStart; iChar < lineEnd && iPlace < wParam - 1; iChar++) { |
|
113 skipped lines |
6225 | | 6305 | | return pdoc->ExtendWordSelect(wParam, 1, lParam != 0); |
|
|
6227 | | 6307 | | case SCI_SETWRAPMODE: |
|
| | 6308 | | switch(wParam){ |
| | 6309 | | case SC_WRAP_WORD: |
| | 6310 | | wrapState = eWrapWord; |
| | 6311 | | break; |
| | 6312 | | case SC_WRAP_CHAR: |
| | 6313 | | wrapState = eWrapChar; |
| | 6314 | | break; |
| | 6315 | | default: |
6228 | | wrapState = (wParam == SC_WRAP_WORD) ? eWrapWord : eWrapNone; | | 6316 | | wrapState = eWrapNone; |
| | 6317 | | break; |
| | 6318 | | } |
|
6230 | | 6320 | | InvalidateStyleRedraw(); |
|
6231 | | 6321 | | ReconfigureScrollBars(); |
|
79 skipped lines |
6311 | | 6401 | | case SCI_GETENDATLASTLINE: |
|
6312 | | 6402 | | return endAtLastLine; |
|
|
| | 6404 | | case SCI_SETCARETSTICKY: |
| | 6405 | | PLATFORM_ASSERT((wParam == 0) || (wParam == 1)); |
| | 6406 | | if (caretSticky != (wParam != 0)) { |
| | 6407 | | caretSticky = wParam != 0; |
| | 6408 | | } |
4 skipped lines |
| | 6413 | | |
| | 6414 | | case SCI_TOGGLECARETSTICKY: |
| | 6415 | | caretSticky = !caretSticky; |
| | 6416 | | break; |
| | 6417 | | |
6314 | | 6418 | | case SCI_GETCOLUMN: |
|
6315 | | 6419 | | return pdoc->GetColumn(wParam); |
|
|
82 skipped lines |
6399 | | 6503 | | int markerID = pdoc->AddMark(wParam, lParam); |
|
6400 | | 6504 | | return markerID; |
|
|
| | 6506 | | case SCI_MARKERADDSET: |
| | 6507 | | if (lParam != 0) |
| | 6508 | | pdoc->AddMarkSet(wParam, lParam); |
| | 6509 | | break; |
|
6403 | | 6511 | | case SCI_MARKERDELETE: |
|
6404 | | 6512 | | pdoc->DeleteMark(wParam, lParam); |
|
213 skipped lines |
6618 | | 6726 | | case SCI_DOCLINEFROMVISIBLE: |
|
6619 | | 6727 | | return cs.DocFromDisplay(wParam); |
|
|
| | 6729 | | case SCI_WRAPCOUNT: |
| | 6730 | | return WrapCount(wParam); |
| | 6731 | | |
6621 | | 6732 | | case SCI_SETFOLDLEVEL: { |
|
6622 | | 6733 | | int prev = pdoc->SetLevel(wParam, lParam); |
|
6623 | | 6734 | | if (prev != lParam) |
|
249 skipped lines |
6873 | | 6984 | | case SCI_LINEENDRECTEXTEND: |
|
6874 | | 6985 | | case SCI_PAGEUPRECTEXTEND: |
|
6875 | | 6986 | | case SCI_PAGEDOWNRECTEXTEND: |
|
| | 6987 | | case SCI_SELECTIONDUPLICATE: |
6876 | | 6988 | | return KeyCommand(iMessage); |
|
|
6878 | | 6990 | | case SCI_BRACEHIGHLIGHT: |
|
7 skipped lines |
6886 | | 6998 | | case SCI_BRACEMATCH: |
|
6887 | | 6999 | | // wParam is position of char to find brace for, |
|
6888 | | 7000 | | // lParam is maximum amount of text to restyle to find it |
|
6889 | | return BraceMatch(wParam, lParam); | | 7001 | | return pdoc->BraceMatch(wParam, lParam); |
|
6891 | | 7003 | | case SCI_GETVIEWEOL: |
|
6892 | | 7004 | | return vs.viewEOL; |
|
210 skipped lines |
7103 | | 7215 | | InvalidateStyleRedraw(); |
|
|
|
| | 7218 | | case SCI_SETPASTECONVERTENDINGS: |
| | 7219 | | convertPastes = wParam != 0; |
| | 7220 | | break; |
| | 7221 | | |
| | 7222 | | case SCI_GETPASTECONVERTENDINGS: |
| | 7223 | | return convertPastes ? 1 : 0; |
| | 7224 | | |
|
7107 | | 7226 | | return DefWndProc(iMessage, wParam, lParam); |
|
|
4 skipped lines |