* @brief Copy selected lines adding linenumbers. */
| 3618 | * @brief Copy selected lines adding linenumbers. |
| 3619 | */ |
| 3620 | void CMergeEditView::OnEditCopyLineNumbers() |
| 3621 | { |
| 3622 | CString strText; |
| 3623 | CString strLine; |
| 3624 | CString strNumLine; |
| 3625 | |
| 3626 | CMergeDoc *pDoc = GetDocument(); |
| 3627 | auto [ptStart, ptEnd] = GetSelection(); |
| 3628 | |
| 3629 | // Get last selected line (having widest linenumber) |
| 3630 | int line = pDoc->m_ptBuf[m_nThisPane]->ComputeRealLine(ptEnd.y); |
| 3631 | size_t nNumWidth = strutils::to_str(line + 1).length(); |
| 3632 | |
| 3633 | for (int i = ptStart.y; i <= ptEnd.y; i++) |
| 3634 | { |
| 3635 | if (GetLineFlags(i) & LF_GHOST || (GetEnableHideLines() && (GetLineFlags(i) & LF_INVISIBLE))) |
| 3636 | continue; |
| 3637 | |
| 3638 | // We need to convert to real linenumbers |
| 3639 | line = pDoc->m_ptBuf[m_nThisPane]->ComputeRealLine(i); |
| 3640 | |
| 3641 | // Insert spaces to align different width linenumbers (99, 100) |
| 3642 | strLine = GetLineText(i); |
| 3643 | CString sSpaces(' ', static_cast<int>(nNumWidth - strutils::to_str(line + 1).length())); |
| 3644 | |
| 3645 | strText += sSpaces; |
| 3646 | strNumLine.Format(_T("%d: %s"), line + 1, (const tchar_t*)strLine); |
| 3647 | strText += strNumLine; |
| 3648 | } |
| 3649 | PutToClipboard(strText, strText.GetLength(), m_bRectangularSelection); |
| 3650 | } |
| 3651 | |
| 3652 | void CMergeEditView::OnUpdateEditCopyLinenumbers(CCmdUI* pCmdUI) |
| 3653 | { |
nothing calls this directly
no test coverage detected