diff --git a/src/document.h b/src/document.h index 2b4c1870..1f6fa7b1 100755 --- a/src/document.h +++ b/src/document.h @@ -914,11 +914,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? @@ -1435,6 +1432,28 @@ struct Document { } return nullptr; + case A_COLLAPSE: { + if (selected.xs * selected.ys == 1) return nullptr; + auto fc = selected.GetFirst(); + fc->parent->AddUndo(this); + loopallcellssel(ci, true) if (ci != fc && ci->text.t.Len()) + fc->text.t += " " + ci->text.t; + loopallcellssel(ci, false) if (ci != fc) ci->Clear(); + if (!fc->HasContent()) return nullptr; + 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 cd015a55..db8f13ea 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..cdc04671 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, _("&Collapse Cells\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"),