diff --git a/src/document.h b/src/document.h index 5118e4b4..7b3a6b5a 100755 --- a/src/document.h +++ b/src/document.h @@ -908,11 +908,8 @@ struct Document { if (uk == WXK_NONE || (k < ' ' && k) || k == WXK_DELETE) { switch (k) { case WXK_BACK: // no menu shortcut available in wxwidgets - if (!ctrl) { - return Action(dc, A_BACKSPACE); - } else { // prevent Ctrl+H from being treated as Backspace - break; - } + if (!ctrl) return Action(dc, A_BACKSPACE); + break; // Prevent Ctrl+H from being treated as Backspace case WXK_RETURN: return Action(dc, shift ? A_ENTERGRID : A_ENTERCELL); case WXK_ESCAPE: // docs say it can be used as a menu accelerator, but it does not // trigger from there? @@ -1429,6 +1426,29 @@ struct Document { } return nullptr; + case A_COLLAPSE: { + if (selected.xs * selected.ys == 1) return _(L"More than one cell must be selected."); + auto fc = selected.GetFirst(); + wxString ct = ""; + loopallcellssel(ci, true) if (ci != fc && ci->text.t.Len()) ct += " " + ci->text.t; + if (!fc->HasContent() && !ct.Len()) return _(L"There is no content to collapse."); + fc->parent->AddUndo(this); + fc->text.t += ct; + loopallcellssel(ci, false) if (ci != fc) ci->Clear(); + Selection deletesel( + selected.g, + selected.x + int(selected.xs > 1), // sidestep is possible? + selected.y + int(selected.ys > 1), + selected.xs - int(selected.xs > 1), + selected.ys - int(selected.ys > 1) + ); + selected.g->MultiCellDeleteSub(this, deletesel); + SetSelect(Selection(selected.g, selected.x, selected.y, 1, 1)); + fc->ResetLayout(); + Refresh(); + return nullptr; + } + case A_SELALL: selected.SelAll(); Refresh(); diff --git a/src/main.cpp b/src/main.cpp index e56ec059..47486940 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,6 +49,7 @@ enum { A_CUT, A_COPY, A_PASTE, + A_COLLAPSE, A_NEWGRID, A_UNDO, A_ABOUT, diff --git a/src/myframe.h b/src/myframe.h index 5b9caa93..c0b38b0d 100755 --- a/src/myframe.h +++ b/src/myframe.h @@ -388,6 +388,7 @@ struct MyFrame : wxFrame { MyAppend(editmenu, A_PASTE, _(L"&Paste\tCTRL+v")); MyAppend(editmenu, A_PASTESTYLE, _(L"Paste Style Only\tCTRL+SHIFT+v"), _(L"only sets the colors and style of the copied cell, and keeps the text")); + MyAppend(editmenu, A_COLLAPSE, _(L"Collapse Ce&lls\tCTRL+l")); editmenu->AppendSeparator(); MyAppend(editmenu, A_UNDO, _(L"&Undo\tCTRL+z"), _(L"revert the changes, one step at a time")); MyAppend(editmenu, A_REDO, _(L"&Redo\tCTRL+y"),