| 3374 | } |
| 3375 | |
| 3376 | void Editor::DrawBlockCaret ( Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, |
| 3377 | int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour ) |
| 3378 | { |
| 3379 | int lineStart = ll->LineStart ( subLine ); |
| 3380 | int posBefore = posCaret; |
| 3381 | int posAfter = MovePositionOutsideChar ( posCaret + 1, 1 ); |
| 3382 | int numCharsToDraw = posAfter - posCaret; |
| 3383 | // Work out where the starting and ending offsets are. We need to |
| 3384 | // see if the previous character shares horizontal space, such as a |
| 3385 | // glyph / combining character. If so we'll need to draw that too. |
| 3386 | int offsetFirstChar = offset; |
| 3387 | int offsetLastChar = offset + ( posAfter - posCaret ); |
| 3388 | while ( ( posBefore > 0 ) && ( ( offsetLastChar - numCharsToDraw ) >= lineStart ) ) { |
| 3389 | if ( ( ll->positions[offsetLastChar] - ll->positions[offsetLastChar - numCharsToDraw] ) > 0 ) { |
| 3390 | // The char does not share horizontal space |
| 3391 | break; |
| 3392 | } |
| 3393 | // Char shares horizontal space, update the numChars to draw |
| 3394 | // Update posBefore to point to the prev char |
| 3395 | posBefore = MovePositionOutsideChar ( posBefore - 1, -1 ); |
| 3396 | numCharsToDraw = posAfter - posBefore; |
| 3397 | offsetFirstChar = offset - ( posCaret - posBefore ); |
| 3398 | } |
| 3399 | // See if the next character shares horizontal space, if so we'll |
| 3400 | // need to draw that too. |
| 3401 | if ( offsetFirstChar < 0 ) { |
| 3402 | offsetFirstChar = 0; |
| 3403 | } |
| 3404 | numCharsToDraw = offsetLastChar - offsetFirstChar; |
| 3405 | while ( ( offsetLastChar < ll->LineStart ( subLine + 1 ) ) && ( offsetLastChar <= ll->numCharsInLine ) ) { |
| 3406 | // Update posAfter to point to the 2nd next char, this is where |
| 3407 | // the next character ends, and 2nd next begins. We'll need |
| 3408 | // to compare these two |
| 3409 | posBefore = posAfter; |
| 3410 | posAfter = MovePositionOutsideChar ( posAfter + 1, 1 ); |
| 3411 | offsetLastChar = offset + ( posAfter - posCaret ); |
| 3412 | if ( ( ll->positions[offsetLastChar] - ll->positions[offsetLastChar - ( posAfter - posBefore )] ) > 0 ) { |
| 3413 | // The char does not share horizontal space |
| 3414 | break; |
| 3415 | } |
| 3416 | // Char shares horizontal space, update the numChars to draw |
| 3417 | numCharsToDraw = offsetLastChar - offsetFirstChar; |
| 3418 | } |
| 3419 | // We now know what to draw, update the caret drawing rectangle |
| 3420 | rcCaret.left = ll->positions[offsetFirstChar] - ll->positions[lineStart] + xStart; |
| 3421 | rcCaret.right = ll->positions[offsetFirstChar + numCharsToDraw] - ll->positions[lineStart] + xStart; |
| 3422 | // Adjust caret position to take into account any word wrapping symbols. |
| 3423 | if ( ( ll->wrapIndent != 0 ) && ( lineStart != 0 ) ) { |
| 3424 | XYPOSITION wordWrapCharWidth = ll->wrapIndent; |
| 3425 | rcCaret.left += wordWrapCharWidth; |
| 3426 | rcCaret.right += wordWrapCharWidth; |
| 3427 | } |
| 3428 | // This character is where the caret block is, we override the colours |
| 3429 | // (inversed) for drawing the caret here. |
| 3430 | int styleMain = ll->styles[offsetFirstChar]; |
| 3431 | surface->DrawTextClipped ( rcCaret, vsDraw.styles[styleMain].font, |
| 3432 | rcCaret.top + vsDraw.maxAscent, ll->chars + offsetFirstChar, |
| 3433 | numCharsToDraw, vsDraw.styles[styleMain].back, |
nothing calls this directly
no test coverage detected