| 1624 | } |
| 1625 | |
| 1626 | void TextareaData::DeletePreviousChar() |
| 1627 | { |
| 1628 | // If cursor is not at the beginning of a line |
| 1629 | if(cursorCharX) |
| 1630 | { |
| 1631 | history->TakeSnapshot(currLine, HistoryManager::LINES_CHANGED, 1); |
| 1632 | // If cursor is in the middle, move characters to the vacant position |
| 1633 | if(cursorCharX != currLine->length) |
| 1634 | memmove(&currLine->data[cursorCharX-1], &currLine->data[cursorCharX], (currLine->length - cursorCharX) * sizeof(AreaChar)); |
| 1635 | // Shrink line size and move cursor |
| 1636 | currLine->length--; |
| 1637 | cursorCharX--; |
| 1638 | // Force redraw on the updated region |
| 1639 | RECT invalid = { 0, (cursorCharY - shiftCharY) * RichTextarea::charHeight, areaWidth, (cursorCharY - shiftCharY + 1) * RichTextarea::charHeight }; |
| 1640 | InvalidateRect(areaWnd, &invalid, false); |
| 1641 | }else if(currLine->prev){ // If it's at the beginning of a line and there is a line before current |
| 1642 | // Add current line to the previous, as if are removing the line break |
| 1643 | currLine = currLine->prev; |
| 1644 | |
| 1645 | history->TakeSnapshot(currLine, HistoryManager::LINES_DELETED, 2); |
| 1646 | // Check if there is enough space |
| 1647 | unsigned int sum = currLine->length + currLine->next->length; |
| 1648 | ExtendLine(currLine, sum); |
| 1649 | // Append one line to the other |
| 1650 | memcpy(&currLine->data[currLine->length], currLine->next->data, currLine->next->length * sizeof(AreaChar)); |
| 1651 | |
| 1652 | // Update cursor position |
| 1653 | cursorCharX = currLine->length; |
| 1654 | cursorCharY--; |
| 1655 | |
| 1656 | // Update line length |
| 1657 | currLine->length = sum; |
| 1658 | |
| 1659 | // Remove line that was current before event |
| 1660 | DeleteLine(currLine->next); |
| 1661 | lineCount--; |
| 1662 | |
| 1663 | // Force redraw on the updated region |
| 1664 | RECT invalid = { 0, (cursorCharY - shiftCharY - 1) * RichTextarea::charHeight, areaWidth, areaHeight }; |
| 1665 | InvalidateRect(areaWnd, &invalid, false); |
| 1666 | } |
| 1667 | } |
| 1668 | |
| 1669 | void TextareaData::OnCopyOrCut(bool cut) |
| 1670 | { |
nothing calls this directly
no test coverage detected