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