Skip to content

Commit

Permalink
Add Copy Selected Difference to Clipboard (#2429)
Browse files Browse the repository at this point in the history
Co-authored-by: z <z@localhost>
  • Loading branch information
lededev and z authored Sep 16, 2024
1 parent d024168 commit 5eb0eaa
Show file tree
Hide file tree
Showing 43 changed files with 481 additions and 41 deletions.
7 changes: 7 additions & 0 deletions Src/Merge.rc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ BEGIN
MENUITEM "Copy Selected Line(s) from Middle", ID_COPY_LINES_FROM_MIDDLE_R
MENUITEM "Copy Selected Line(s) from Left", ID_COPY_LINES_FROM_LEFT_R
MENUITEM SEPARATOR
MENUITEM "&Copy Selected Diff (Left) to Clipboard\tCtrl+1", ID_SEL_DIFF_COPY_L
MENUITEM "&Copy Selected Diff (Mid) to Clipboard\tCtrl+2", ID_SEL_DIFF_COPY_M
MENUITEM "&Copy Selected Diff (Right) to Clipboard\tCtrl+3", ID_SEL_DIFF_COPY_R
MENUITEM SEPARATOR
MENUITEM "Select Line &Difference\tF4", ID_SELECTLINEDIFF
MENUITEM "Add this change to Substitution &Filters", ID_ADD_TO_IGNORED_SUBSTITUTIONS
MENUITEM "Add to &Line Filters", ID_ADD_TO_LINE_FILTERS
Expand Down Expand Up @@ -1385,6 +1389,9 @@ BEGIN
VK_OEM_MINUS, ID_VIEW_ZOOMOUT, VIRTKEY, CONTROL, NOINVERT
VK_MULTIPLY, ID_VIEW_ZOOMNORMAL, VIRTKEY, CONTROL, NOINVERT
"0", ID_VIEW_ZOOMNORMAL, VIRTKEY, CONTROL, NOINVERT
"1", ID_SEL_DIFF_COPY_L, VIRTKEY, CONTROL, NOINVERT
"2", ID_SEL_DIFF_COPY_M, VIRTKEY, CONTROL, NOINVERT
"3", ID_SEL_DIFF_COPY_R, VIRTKEY, CONTROL, NOINVERT
END


Expand Down
81 changes: 81 additions & 0 deletions Src/MergeEditView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ BEGIN_MESSAGE_MAP(CMergeEditView, CCrystalEditViewEx)
ON_UPDATE_COMMAND_UI_RANGE(ID_COPY_TO_MIDDLE_L, ID_COPY_FROM_LEFT_R, OnUpdateX2Y)
ON_COMMAND_RANGE(ID_COPY_LINES_TO_MIDDLE_L, ID_COPY_LINES_FROM_LEFT_R, OnCopyLinesX2Y)
ON_UPDATE_COMMAND_UI_RANGE(ID_COPY_LINES_TO_MIDDLE_L, ID_COPY_LINES_FROM_LEFT_R, OnUpdateX2Y)
ON_COMMAND(ID_SEL_DIFF_COPY_L, OnSelDiffCopyLeft)
ON_UPDATE_COMMAND_UI(ID_SEL_DIFF_COPY_L, OnUpdateSelDiffCopyLeft)
ON_COMMAND(ID_SEL_DIFF_COPY_M, OnSelDiffCopyMid)
ON_UPDATE_COMMAND_UI(ID_SEL_DIFF_COPY_M, OnUpdateSelDiffCopyMid)
ON_COMMAND(ID_SEL_DIFF_COPY_R, OnSelDiffCopyRight)
ON_UPDATE_COMMAND_UI(ID_SEL_DIFF_COPY_R, OnUpdateSelDiffCopyRight)
// [Plugins] menu
ON_COMMAND_RANGE(ID_SCRIPT_FIRST, ID_SCRIPT_LAST, OnScripts)
ON_COMMAND(ID_TRANSFORM_WITH_SCRIPT, OnTransformWithScript)
Expand Down Expand Up @@ -2083,6 +2089,81 @@ void CMergeEditView::OnCopyLinesX2Y(UINT nID)
OnX2Y(srcPane, dstPane, true);
}

void CMergeEditView::SelDiffCopy(int actPane)
{
CMergeDoc* pDoc = GetDocument();
const auto cntPane = pDoc->m_nBuffers;
const auto currentDiff = pDoc->GetCurrentDiff();

// Check
if (actPane < 0 || actPane > 2 || cntPane < 1 || currentDiff < 0)
return;
if (2 == cntPane && actPane >= cntPane)
actPane = 1;

DIFFRANGE di;
if (!pDoc->m_diffList.GetDiff(currentDiff, di))
return;
CDiffTextBuffer& buf = *(pDoc->m_ptBuf[actPane]);
const auto beginidx = buf.ComputeApparentLine(di.begin[actPane]);
const auto endidx = buf.ComputeApparentLine(di.end[actPane]);
if (beginidx > endidx)
return;
String dfLines;
const auto endlen = buf.GetLineLength(endidx);
buf.GetTextWithoutEmptys(beginidx, 0, endidx, endlen, dfLines);
dfLines += buf.GetLineEol(endidx);

if (OpenClipboard())
{
EmptyClipboard();
const size_t len = (dfLines.length() + 1) * sizeof(tchar_t);
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, len);
if (hGlobal)
{
LPTSTR pGlobal = (LPTSTR)GlobalLock(hGlobal);
if (pGlobal)
{
memcpy(pGlobal, dfLines.c_str(), len);
GlobalUnlock(hGlobal);
SetClipboardData(CF_UNICODETEXT, hGlobal);
}
GlobalFree(hGlobal);
}

CloseClipboard();
}
}

void CMergeEditView::OnSelDiffCopyLeft()
{
SelDiffCopy(0);
}
void CMergeEditView::OnUpdateSelDiffCopyLeft(CCmdUI* pCmdUI)
{
pCmdUI->Enable(GetDocument()->GetCurrentDiff() >= 0 && GetDocument()->m_nBuffers > 0);
}

void CMergeEditView::OnSelDiffCopyMid()
{
SelDiffCopy(1);
}

void CMergeEditView::OnUpdateSelDiffCopyMid(CCmdUI* pCmdUI)
{
pCmdUI->Enable(GetDocument()->GetCurrentDiff() >= 0 && GetDocument()->m_nBuffers > 2);
}

void CMergeEditView::OnSelDiffCopyRight()
{
SelDiffCopy(2);
}

void CMergeEditView::OnUpdateSelDiffCopyRight(CCmdUI* pCmdUI)
{
pCmdUI->Enable(GetDocument()->GetCurrentDiff() >= 0 && GetDocument()->m_nBuffers > 1);
}

/**
* @brief Copy diff from left pane to right pane
*
Expand Down
7 changes: 7 additions & 0 deletions Src/MergeEditView.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class CMergeEditView : public CGhostTextView
void OnPrev3wayDiff(int type);
void OnUpdatePrev3wayDiff(CCmdUI* pCmdUI, int type);
void OnDropFiles(const std::vector<String>& files);
void SelDiffCopy(int actPane);

// Generated message map functions
protected:
Expand Down Expand Up @@ -265,6 +266,12 @@ class CMergeEditView : public CGhostTextView
afx_msg void OnUpdateCopyFromRight(CCmdUI* pCmdUI);
afx_msg void OnCopyLinesFromRight();
afx_msg void OnUpdateCopyLinesFromRight(CCmdUI* pCmdUI);
afx_msg void OnSelDiffCopyLeft();
afx_msg void OnUpdateSelDiffCopyLeft(CCmdUI* pCmdUI);
afx_msg void OnSelDiffCopyMid();
afx_msg void OnUpdateSelDiffCopyMid(CCmdUI* pCmdUI);
afx_msg void OnSelDiffCopyRight();
afx_msg void OnUpdateSelDiffCopyRight(CCmdUI* pCmdUI);
afx_msg void OnAddSyncPoint();
afx_msg void OnClearSyncPoints();
afx_msg void OnUpdateClearSyncPoints(CCmdUI* pCmdUI);
Expand Down
3 changes: 3 additions & 0 deletions Src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,9 @@
#define ID_COPY_LINES_FROM_RIGHT 33264
#define ID_LINES_L2R 33265
#define ID_LINES_R2L 33266
#define ID_SEL_DIFF_COPY_L 33271
#define ID_SEL_DIFF_COPY_M 33272
#define ID_SEL_DIFF_COPY_R 33273
#define ID_TABBAR_AUTO_MAXWIDTH 33351
#define ID_IMG_VIEWDIFFERENCES 33353
#define ID_IMG_ZOOM_25 33354
Expand Down
80 changes: 40 additions & 40 deletions Translations/TranslationsStatus.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
# Translations Status

Status from **2024-07-25**:
Status from **2024-09-15**:

## WinMerge

| Language | Total | Translated | Fuzzy | Untranslated | Complete | Last Update |
|:---------------------|------:|-----------:|------:|-------------:|---------:|:-----------:|
| Arabic | 1392 | 895 | 0 | 497 | 64 % | 2019-12-30 |
| Basque | 1392 | 638 | 0 | 754 | 45 % | 2013-02-03 |
| Brazilian | 1392 | 1392 | 0 | 0 | 100 % | 2024-07-24 |
| Bulgarian | 1392 | 1078 | 0 | 314 | 77 % | 2023-11-14 |
| Catalan | 1392 | 1328 | 0 | 64 | 95 % | |
| ChineseSimplified | 1392 | 1392 | 0 | 0 | 100 % | |
| ChineseTraditional | 1392 | 1293 | 0 | 99 | 92 % | 2022-02-19 |
| Corsican | 1392 | 1389 | 0 | 3 | 99 % | 2024-06-21 |
| Croatian | 1392 | 630 | 1 | 761 | 45 % | 2009-02-13 |
| Czech | 1392 | 605 | 0 | 787 | 43 % | |
| Danish | 1392 | 639 | 0 | 753 | 45 % | 2013-01-13 |
| Dutch | 1392 | 1280 | 0 | 112 | 91 % | 2023-05-02 |
| English | 1392 | 1392 | 0 | 0 | 100 % | 2024-07-23 |
| Finnish | 1392 | 1185 | 0 | 207 | 85 % | |
| French | 1392 | 1389 | 0 | 3 | 99 % | 2024-06-14 |
| Galician | 1392 | 1317 | 0 | 75 | 94 % | 2023-11-24 |
| German | 1392 | 1342 | 0 | 50 | 96 % | 2023-08-08 |
| Greek | 1392 | 605 | 0 | 787 | 43 % | |
| Hungarian | 1392 | 1392 | 0 | 0 | 100 % | 2021-03-15 |
| Italian | 1392 | 1375 | 0 | 17 | 98 % | 2024-04-27 |
| Japanese | 1392 | 1392 | 0 | 0 | 100 % | 2024-06-22 |
| Korean | 1392 | 1389 | 0 | 3 | 99 % | 2024-05-22 |
| Lithuanian | 1392 | 1343 | 0 | 49 | 96 % | 2024-07-24 |
| Norwegian | 1392 | 730 | 0 | 662 | 52 % | |
| Persian | 1392 | 641 | 0 | 751 | 46 % | 2013-08-15 |
| Polish | 1392 | 1355 | 0 | 37 | 97 % | 2023-11-28 |
| Portuguese | 1392 | 1389 | 0 | 3 | 99 % | 2024-05-10 |
| Romanian | 1392 | 1306 | 0 | 86 | 93 % | 2023-11-07 |
| Russian | 1392 | 1318 | 0 | 74 | 94 % | 2023-04-27 |
| Serbian | 1392 | 632 | 0 | 760 | 45 % | |
| Sinhala | 1392 | 563 | 58 | 771 | 44 % | 2010-12-12 |
| Slovak | 1392 | 1184 | 0 | 208 | 85 % | 2022-02-17 |
| Slovenian | 1392 | 1320 | 0 | 72 | 94 % | 2024-01-28 |
| Spanish | 1392 | 1317 | 0 | 75 | 94 % | 2023-11-24 |
| Swedish | 1392 | 1232 | 2 | 158 | 88 % | 2023-02-08 |
| Tamil | 1392 | 1218 | 0 | 174 | 87 % | 2023-07-24 |
| Turkish | 1392 | 1326 | 0 | 66 | 95 % | 2023-10-28 |
| Ukrainian | 1392 | 708 | 0 | 684 | 50 % | 2009-06-13 |
| Arabic | 1395 | 895 | 0 | 500 | 64 % | 2019-12-30 |
| Basque | 1395 | 638 | 0 | 757 | 45 % | 2013-02-03 |
| Brazilian | 1395 | 1392 | 0 | 3 | 99 % | 2024-07-30 |
| Bulgarian | 1395 | 1078 | 0 | 317 | 77 % | 2023-11-14 |
| Catalan | 1395 | 1328 | 0 | 67 | 95 % | |
| ChineseSimplified | 1395 | 1392 | 0 | 3 | 99 % | |
| ChineseTraditional | 1395 | 1293 | 0 | 102 | 92 % | 2022-02-19 |
| Corsican | 1395 | 1389 | 0 | 6 | 99 % | 2024-06-21 |
| Croatian | 1395 | 630 | 1 | 764 | 45 % | 2009-02-13 |
| Czech | 1395 | 605 | 0 | 790 | 43 % | |
| Danish | 1395 | 639 | 0 | 756 | 45 % | 2013-01-13 |
| Dutch | 1395 | 1280 | 0 | 115 | 91 % | 2023-05-02 |
| English | 1395 | 1395 | 0 | 0 | 100 % | 2024-09-15 |
| Finnish | 1395 | 1185 | 0 | 210 | 84 % | |
| French | 1395 | 1392 | 0 | 3 | 99 % | 2024-08-01 |
| Galician | 1395 | 1317 | 0 | 78 | 94 % | 2023-11-24 |
| German | 1395 | 1342 | 0 | 53 | 96 % | 2023-08-08 |
| Greek | 1395 | 605 | 0 | 790 | 43 % | |
| Hungarian | 1395 | 1392 | 0 | 3 | 99 % | 2021-03-15 |
| Italian | 1395 | 1392 | 0 | 3 | 99 % | 2024-07-27 |
| Japanese | 1395 | 1392 | 0 | 3 | 99 % | 2024-07-27 |
| Korean | 1395 | 1392 | 0 | 3 | 99 % | 2024-09-13 |
| Lithuanian | 1395 | 1343 | 0 | 52 | 96 % | 2024-07-24 |
| Norwegian | 1395 | 730 | 0 | 665 | 52 % | |
| Persian | 1395 | 641 | 0 | 754 | 45 % | 2013-08-15 |
| Polish | 1395 | 1355 | 0 | 40 | 97 % | 2023-11-28 |
| Portuguese | 1395 | 1392 | 0 | 3 | 99 % | 2024-08-17 |
| Romanian | 1395 | 1306 | 0 | 89 | 93 % | 2023-11-07 |
| Russian | 1395 | 1318 | 0 | 77 | 94 % | 2023-04-27 |
| Serbian | 1395 | 632 | 0 | 763 | 45 % | |
| Sinhala | 1395 | 563 | 58 | 774 | 44 % | 2010-12-12 |
| Slovak | 1395 | 1184 | 0 | 211 | 84 % | 2022-02-17 |
| Slovenian | 1395 | 1320 | 0 | 75 | 94 % | 2024-01-28 |
| Spanish | 1395 | 1317 | 0 | 78 | 94 % | 2023-11-24 |
| Swedish | 1395 | 1232 | 2 | 161 | 88 % | 2023-02-08 |
| Tamil | 1395 | 1218 | 0 | 177 | 87 % | 2023-07-24 |
| Turkish | 1395 | 1326 | 0 | 69 | 95 % | 2023-10-28 |
| Ukrainian | 1395 | 708 | 0 | 687 | 50 % | 2009-06-13 |

## ShellExtension

Expand Down Expand Up @@ -274,6 +274,7 @@ Status from **2024-07-25**:
- [Rukoto Luther](mailto:rukotolucies%20at%20hotmail.com)

* Korean
- [VenusGirl](mailto:VenusGirl%20at%20https://github.com/VenusGirl)
- [Hwang Sukjoon](mailto:bbcool%20at%20gmail.com)
- [Lee Jae-Hong](mailto:pyrasis%20at%20users.sourceforge.net)
- [Sushizang](mailto:sushizang%20at%20empal.com)
Expand All @@ -282,7 +283,6 @@ Status from **2024-07-25**:
- [BrainS](mailto:29201475+BraINstinct0%20at%20users.noreply.github.com)
- [cynilyn](mailto:cynilyn%20at%20gmail.com)
- [gro00](mailto:gheong.ro%20at%20gmail.com)
- [VenusGirl](mailto:VenusGirl%20at%20https://github.com/VenusGirl)

* Lithuanian
- [Dalius Guzauskas (aka Tichij)](mailto:tichij%20AT%20mail%20DOT%20com)
Expand Down
9 changes: 9 additions & 0 deletions Translations/WinMerge/Arabic.po
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ msgstr ""
msgid "Copy Selected Line(s) from Left"
msgstr ""

msgid "&Copy Selected Diff (Left) to Clipboard\tCtrl+1"
msgstr ""

msgid "&Copy Selected Diff (Mid) to Clipboard\tCtrl+2"
msgstr ""

msgid "&Copy Selected Diff (Right) to Clipboard\tCtrl+3"
msgstr ""

msgid "Select Line &Difference\tF4"
msgstr "تحديد الاختلاف في السطر"

Expand Down
9 changes: 9 additions & 0 deletions Translations/WinMerge/Basque.po
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ msgstr ""
msgid "Copy Selected Line(s) from Left"
msgstr ""

msgid "&Copy Selected Diff (Left) to Clipboard\tCtrl+1"
msgstr ""

msgid "&Copy Selected Diff (Mid) to Clipboard\tCtrl+2"
msgstr ""

msgid "&Copy Selected Diff (Right) to Clipboard\tCtrl+3"
msgstr ""

#, c-format
msgid "Select Line &Difference\tF4"
msgstr "Hautatu Lerro &Ezberdintasunak\tF4"
Expand Down
9 changes: 9 additions & 0 deletions Translations/WinMerge/Brazilian.po
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ msgstr "Copiar a(s) linha(s) selecionada(s) pra esquerda"
msgid "Copy Selected Line(s) from Left"
msgstr "Copiar a(s) linha(s) selecionada(s) da esquerda"

msgid "&Copy Selected Diff (Left) to Clipboard\tCtrl+1"
msgstr ""

msgid "&Copy Selected Diff (Mid) to Clipboard\tCtrl+2"
msgstr ""

msgid "&Copy Selected Diff (Right) to Clipboard\tCtrl+3"
msgstr ""

msgid "Select Line &Difference\tF4"
msgstr "Selecionar a &Diferença da Linha\tF4"

Expand Down
9 changes: 9 additions & 0 deletions Translations/WinMerge/Bulgarian.po
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ msgstr "Копиране избраните редове вляво"
msgid "Copy Selected Line(s) from Left"
msgstr "Копиране избраните редове от ляво"

msgid "&Copy Selected Diff (Left) to Clipboard\tCtrl+1"
msgstr ""

msgid "&Copy Selected Diff (Mid) to Clipboard\tCtrl+2"
msgstr ""

msgid "&Copy Selected Diff (Right) to Clipboard\tCtrl+3"
msgstr ""

msgid "Select Line &Difference\tF4"
msgstr "&Избиране на различията на реда\tF4"

Expand Down
9 changes: 9 additions & 0 deletions Translations/WinMerge/Catalan.po
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ msgstr "Copia les línies seleccionades a l'esquerra"
msgid "Copy Selected Line(s) from Left"
msgstr "Copia les línies seleccionades de l'esquerra"

msgid "&Copy Selected Diff (Left) to Clipboard\tCtrl+1"
msgstr ""

msgid "&Copy Selected Diff (Mid) to Clipboard\tCtrl+2"
msgstr ""

msgid "&Copy Selected Diff (Right) to Clipboard\tCtrl+3"
msgstr ""

#, c-format
msgid "Select Line &Difference\tF4"
msgstr "Selecciona la diferència de la &línia\tF4"
Expand Down
9 changes: 9 additions & 0 deletions Translations/WinMerge/ChineseSimplified.po
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ msgstr "复制选中行到左侧"
msgid "Copy Selected Line(s) from Left"
msgstr "从左侧复制选中行"

msgid "&Copy Selected Diff (Left) to Clipboard\tCtrl+1"
msgstr "复制选中差异(左)到剪贴板\tCtrl+1"

msgid "&Copy Selected Diff (Mid) to Clipboard\tCtrl+2"
msgstr "复制选中差异(中)到剪贴板\tCtrl+2"

msgid "&Copy Selected Diff (Right) to Clipboard\tCtrl+3"
msgstr "复制选中差异(右)到剪贴板\tCtrl+3"

msgid "Select Line &Difference\tF4"
msgstr "选中行内差异(&D)\tF4"

Expand Down
9 changes: 9 additions & 0 deletions Translations/WinMerge/ChineseTraditional.po
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ msgstr "將所選行複製到左側"
msgid "Copy Selected Line(s) from Left"
msgstr "從左側複製所選行"

msgid "&Copy Selected Diff (Left) to Clipboard\tCtrl+1"
msgstr ""

msgid "&Copy Selected Diff (Mid) to Clipboard\tCtrl+2"
msgstr ""

msgid "&Copy Selected Diff (Right) to Clipboard\tCtrl+3"
msgstr ""

#, c-format
msgid "Select Line &Difference\tF4"
msgstr "選取行內差異 (&D)\tF4"
Expand Down
9 changes: 9 additions & 0 deletions Translations/WinMerge/Corsican.po
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ msgstr "Cupià a(e) linea(e) selezziunata(e) versu a manca"
msgid "Copy Selected Line(s) from Left"
msgstr "Cupià a(e) linea(e) selezziunata(e) da a manca"

msgid "&Copy Selected Diff (Left) to Clipboard\tCtrl+1"
msgstr ""

msgid "&Copy Selected Diff (Mid) to Clipboard\tCtrl+2"
msgstr ""

msgid "&Copy Selected Diff (Right) to Clipboard\tCtrl+3"
msgstr ""

msgid "Select Line &Difference\tF4"
msgstr "&Selezziunà a sfarenza di linea\tF4"

Expand Down
9 changes: 9 additions & 0 deletions Translations/WinMerge/Croatian.po
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ msgstr ""
msgid "Copy Selected Line(s) from Left"
msgstr ""

msgid "&Copy Selected Diff (Left) to Clipboard\tCtrl+1"
msgstr ""

msgid "&Copy Selected Diff (Mid) to Clipboard\tCtrl+2"
msgstr ""

msgid "&Copy Selected Diff (Right) to Clipboard\tCtrl+3"
msgstr ""

#, c-format
msgid "Select Line &Difference\tF4"
msgstr "Istakni &razliku\tF4"
Expand Down
Loading

0 comments on commit 5eb0eaa

Please sign in to comment.