| 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; |